Winforms app - classes not getting GCd

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

Comments

  • Hi,

    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:
    http://www.red-gate.com/messageboard/viewforum.php?f=92

    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.

    Regards,

    Stephen
  • 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.
Sign In or Register to comment.