FIX: An application that uses MDI Child Forms and menus leaks Win32 resources (330203)



The information in this article applies to:

  • Microsoft .NET Framework 1.0
  • Microsoft .NET Framework SDK 1.0
  • Microsoft .NET Framework SDK 1.0 SP1
  • Microsoft .NET Framework SDK 1.0 SP2

This article was previously published under Q330203

SYMPTOMS

Microsoft Win32 resources that are used by Multiple Document Interface (MDI) Child Forms with menus are not returned to the operating system if the MDI Child Form is closed or is disposed of. This behavior only occurs if the time the application that uses MDI Child Forms terminates.

RESOLUTION

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next Microsoft .NET Framework service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date         Time   Version       Size       File name
   ---------------------------------------------------------------------
   04-Oct-2002  08:40  1.0.3705.365  1,179,648  system.data.dll
   04-Oct-2002  08:35  1.0.3705.365  1,986,560  system.windows.forms.dll
   03-Oct-2002  21:33                   16,688  system.windows.forms.ldo
   03-Oct-2002  21:29  1.0.3705.365     57,344  system.windows.forms.tlb
				

MORE INFORMATION

Steps to reproduce the problem

  1. Create a Windows Application by using Microsoft Visual C# .NET.
  2. Add an MDI Child Form, and then set the value of the IsMdiContainer property to True in the Properties window.
  3. Add a Form that is named ChildForm, and then add five MainMenu controls to the ChildForm form.
  4. Add eight menu items to each MainMenu control.
  5. Add a MainMenu control with the following text to the MDI Child Form:

    Test Menu Resource Leak

  6. Add a menu item that is named menuItemCreateChilds with the text "Create Child Windows" to the MainMenu control that you added in step 5, and then add the following event handler:
    private void menuItemCreateChilds_Click(object sender, System.EventArgs e) {
    				for(int i=0; i<20; i++)
    				{
    					ChildForm child = new ChildForm();
    					child.MdiParent = this;
    					child.Show();
    				}
    		}
    
  7. Add a menu item that is named menuItemCloseChilds wth the text "Close Child Windows" to the MainMenu control that you added in step 5, and then add the following event handler:
    		private void menuItemCloseChilds_Click(object sender, System.EventArgs e) 
    		{
    			while(MdiChildren.Length>0)
    			{
    				MdiChildren[0].Close();
    				MdiChildren[0].Dispose();
    			}
    			GC.Collect();
    			GC.WaitForPendingFinalizers();
    		}
    
    
  8. Open Windows Task Manager.
  9. Click the Process tab
  10. On the View menu, click Select Columns.
  11. In the Select Columns dialog box, click to select the USER Objects check box, and then click OK to add the column to the process list.
  12. In Visual Studio .NET, build and then run the Windows Application project.
  13. Click Create Child Windows several times, and then click Close Child Windows several times. You will notice a large increase in the USER Objects of the application in Task Manager.

Modification Type:MinorLast Reviewed:10/11/2005
Keywords:kbHotfixServer kbQFE kbbug kbfix kbNetFrame100preSP3fix KB330203 kbAudDeveloper