Use this forum to discuss subjects that don't belong in the other forums.
- Posts: 2
- Joined: Tue Feb 16, 2010 8:48 pm
I am trying to find the memory leak(s) in one of our apps. When I take a snapshot (after opening/closing a child form) I see that there is an instance with a Direct EventHandler root. I click on the instance # to see the Type instance details but I can't find the name of the control causing the issue. I look on the Reference by, References and field value tabs and don't see it. Is there somewhere else I need to be looking?
- Posts: 1000
- Joined: Wed Mar 02, 2005 7:53 pm
If you investigate the root paths of the instance that has direct event handler roots, you should often be able to identify the instance (e.g. a Control instance) that is causing the issue. In the screenshot below, Form1 instance #49,617 owns the EventHandler that is causing the issue.
The field name that is used for the EventHandler can often provide a clue about the actual event that is keeping the reference. In the screenshot below, the idleHandler field is used to store a reference to an EventHandler that has been added to the Application.Idle event.
To minimize memory overhead, Windows Forms controls often use an EventHandlerList to store event handlers. This makes it a bit harder to identify the actual event. The allocation call stack of the EventHandler at the top of the root path (#22476 in the screenshot below) will provide information about why the event handler was added. This information is often all you need to identify the event, but to get additional information, the ListEntry can also be investigated.
The screenshot below shows the field values of ListEntry #22,480. The key field can be used to identify the event.
Double clicking the key reveals the following root path for the key:
From this you can draw the conclusion that the event handler was added to the Form.Activated event.
SciTech Software AB
Users browsing this forum: No registered users and 1 guest