I don't know all the internal details but the amount of memory shown to be
used by your app in Task Manager isn't really the amount being used, it's
more like the amount of memory reserved. I think the concept is that if your
app needed some memory for the second form it'll probably neeed that memory
again sometime soon so it doesn't immediately give it back to windows.
To see this effect create a new WinForms app with no controls and run it. If
you check Task Manager you'll see it's taking up around 15 Mb (that's the
number on my machine). Now minimize the app, you'll notice that Task Manager
now reports that your app is using less than 1 Mb (about 880 Kb on my
machine).
For more details check out this blog post by Rick Strahl.
http://west-wind.com/weblog/posts/240.aspx
Also, you should check out this blog post I made on garbage collection, it's
one of the mosty misunderstood parts of the Common Language Runtime.
http://msmvps.com/windsor/archive/2004/05/18/6706.aspx
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"macqcyr" <ma*****@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com...
I am currently having the same problem. The closing of the window and
calling GC.Collect should work but for some reason the destructor of the MDI child
form is not called (therefore it prevents its child controls of being
destructed).
If instead of opening the the child form as MDI you open it as a modal
dialog its destructor gets then called. This makes me think there is a bug
in System.Windows.Forms.
"mao" wrote:
I hope someone can answer this question for me. I have two forms. One
form is an MDI form and the second form contains many controls, such as
panel, list box, etc. When I open this second form I noticed the application
memory usage. After closing this form, memory stays the same. I thought that
after closing this second from memory usage would be redurced, but it doesn't.
I tried all sort of methods, such as calling GC.Collect(), using
destructor ~, but nothing seems to work Can someone show me an effective method of
calling GC on demand?
Thanks a bunch!