Red Gate forums :: View topic - Confused as to why an object is reported as leaked...
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
ANTS Profiler Previous Versions
ANTS Profiler Previous Versions forum

Confused as to why an object is reported as leaked...

Search in ANTS Profiler Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
tribbles



Joined: 13 Feb 2009
Posts: 2
Location: USA

PostPosted: Fri Feb 13, 2009 1:18 am    Post subject: Confused as to why an object is reported as leaked... Reply with quote

I just can't figure out what is holding onto the reference... I run the garbage collector and look at the objects left and this simpel dialog editor is in the list... I look at what references it and I see a couple 'EventHandler ID 633610' and HScrollProperties ID 629023' and such, both I am unable to trace those back to anything in my code...

Going thru 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.


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't figure out why it is being reported as a leak... The parent class of this code is a UITypeEditor and it gets called from the MS property grid.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6644

PostPosted: Fri Feb 13, 2009 6:22 pm    Post subject: Reply with quote

Hi,

It sounds like the infamous "event handler" gotcha in .NET. If you hook an event handler to an object, you must remember to dereference it when no longer needed. There could also be unintended references created inside the event handler as in the ASP .NET DataGrid example pointed out here.
Back to top
View user's profile Send private message
tribbles



Joined: 13 Feb 2009
Posts: 2
Location: USA

PostPosted: Fri Feb 13, 2009 6:26 pm    Post subject: Reply with quote

I have not attached any events to the dialog form. All events within the form reference to objects on the form. i.e. change events to several check boxes and text boxes on the dialog form. There is also a finalizer referencing the dialog form as well, which seems odd.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group