Winforms app - classes not getting GCd

Code and memory profiling for .NET developers.

Winforms app - classes not getting GCd

Postby mnadig » Tue Apr 28, 2009 4:02 pm

In my winforms application, each "form" is actually a usercontrol that is placed in a panel. When the user selects a menu item, the current "form" is removed from the panel and explicitly disposed before newing up the next usercontrol and adding it to the panel's controls collection. Using memory profiling, I see that some of my "forms" aren't going away after calling dispose(). I click GC now and take a snapshot and see that they're still listed in live objects. How can I determine what is preventing it from GC?

thank you
Posts: 4
Joined: Tue Apr 28, 2009 3:43 pm

Postby StephenC » Tue Apr 28, 2009 5:22 pm


the easiest way would be to try the upcoming V5 which has an 'Object Retention Graph' showing you which other objects are still holding references to an instance you are interested in and therefore preventing garbage collection.

You can try the early access build from here:

There are a set of filters available which you will find very helpful by the sounds of it. One of them checks for objects where Dispose was called but the object is still in memory.

Feedback is very much appreciated on this early access version of V5 if you can spare a few minutes when finished profiling.


Posts: 305
Joined: Mon Oct 15, 2007 8:18 am
Location: Cambridge

Postby mnadig » Tue Apr 28, 2009 7:08 pm

Thank you for the quick reply. Downloaded and just watched Part 1 on the How to with v5 videos on youtube (in 2 parts). I'm looking forward to Part 2. Meanwhile, I'll give it a go and provide feedback.
Posts: 4
Joined: Tue Apr 28, 2009 3:43 pm

Return to ANTS Profiler Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests