I'm need help figuring out what is keeping an object from being collected...

My instinctual response is that the tool is bugged...  It is reporting that one of my pop-up dialogs is new after a profile run and not as dead or garbage collected...  When I try to find what is holdign a reference all I see are a couple event handlers...  Goig nthru my code, I only reference the form once in the code segement below.  I have verified that code execution runs all of this code and that the Dispose method is called on the form.  I can find no other references to this form and can not fathom how in blue blazes can this be reported as a leak.  I'm running the trial version and I was testing it out to see if it would be easier to use than ANTS.  Perhaps I am mis understanding somethign fundamental...  The object was opened with new tab for Held and Reachable, both reporting objects in their view...  If I understood the limited documentation correctly, if the object had been properly disposed off, it would have no held objects...

using (GaugeIndicatorEditorForm form = new GaugeIndicatorEditorForm(copy)) {

     if (form.ShowDialog() == DialogResult.OK) {
          gauge.GaugeContainer = GaugeContainer;

           EditorUtil.HostComponentChanged(context, gauge.GaugeContainer);

          if (preview != null) {
               preview.DundasRenderDundas(gauge.GaugeContainer, false);


Cut and paste doesn't work for code apparently, so I had to clean it up by hand, hopefully I didn't delete an paren or semi colon by accident.  Either way, with code this fricken simple, I just can figure out why it is beign reported as a leak...  The parent class of this code is a UITypeEditor and it gets called from the MS property grid.

p.s. Everytime I post is frags the code snippet...  A little less each time, but man irritating...


Dear Charles,

I only see the one way when the GaugeIndicatorEditorForm hasn't been collected. This form signed for an event by itself. Could you send me the source code of your form and the memory snapshot.
My e-mail is Mikhail (dot) Pilin (a) JetBrains (dor) com


I put a try finally around that code block and put an GC.Collect(); in the finally.  The form no longer shows as leaked.  I'm not sure if that is expected or not.


Please sign in to leave a comment.