| Author |
Message |
tribbles
Joined: 13 Feb 2009 Posts: 2 Location: USA
|
Posted: Fri Feb 13, 2009 1:18 am Post subject: Confused as to why an object is reported as leaked... |
|
|
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 |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6345 Location: Red Gate Software
|
Posted: Fri Feb 13, 2009 6:22 pm Post subject: |
|
|
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. _________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
tribbles
Joined: 13 Feb 2009 Posts: 2 Location: USA
|
Posted: Fri Feb 13, 2009 6:26 pm Post subject: |
|
|
| 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 |
|
 |
|
|
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