Memory Leak when disposing of .Net child Winform with mainmenu

June 18, 2006 at 5:23 pm Leave a comment

I had an application recently that has a child window with a mainmenu. I begin noticing that memory weren't being released even when I dispose of the child form. I decided to do an experiment by creating a simple app that creates 10 child window and closes then each time a button is press. The form are disposed of immediately after they are closed. I then examine the run under the CLRProfiler.

What seems to be happening is that the event handler for the form prevent the child form from being garbage collected. However, this is technically not a leak, since after about 250 form objects are on the heap, some of the child forms are cleaned up. It's just that the CLR seems to be holding on to the child form longer than normal due to the menuitem event handler.

I tried this under VS.Net 2005 and notice that the problem does not occur, so it only affects VS.Net 2003. It's also possible that Microsoft may have a patch for this problem for VS.Net 2003, but I did not see it mentioned when I search MSDN.

Entry filed under: .Net, Winform.

Switching off the tap in Synaptic Touchpad in Linux Switching on PowerNow in Linux

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


June 2006
« May   Jul »

Most Recent Posts

%d bloggers like this: