Postby andycsmith » Mon Mar 31, 2008 3:16 pm
I using the profiler to trace a memory leak we are having with our application, i'm reasonable sure I have tracked down the problem but I would like confirmation that I have interprated the results corectly.
This is what i'm getting in the Type instance details
Myriad.Controls FilterBar #61,149._cboFilterColumn
Myriad.Controls DataGridView #61,148
Microsoft.Win32 UserPreferenceChangedEventHandler #67,071._target
Microsoft.Win32 SystemEvents.SystemEventInvokeInfo #67,072._delegate
Microsoft.Win32 SystemEvents.SystemEventInvokeInfo[] #60,685
System.Collections.Generic List<SystemEvents.SystemEventInvokeInfo> #6,591._items
System.Collections.Generic Dictionary<object, List<SystemEvents.SystemEventInvokeInfo>>.Entry[] #6,531[2].value
System.Collections.Generic Dictionary<object, List<SystemEvents.SystemEventInvokeInfo>> #6,533.entries
Microsoft.Win32 SystemEvents _handlers
Double clicking on the SystemEvents.SystemEventInvokeInfo line gives me
SystemEvents.AddEventHandler(object, Delegate)
SystemEvents.add_UserPreferenceChanged(UserPreferenceChangedEventHandler)
DataGridView..ctor()
frmContactTab.InitializeComponent()
frmContactTab..ctor(int, Form)
frmContactMDI.OpenDetails()
frmContactMDI.frmContactMDI_Load(object, EventArgs)
Which to me indicates that an event handler is being added for UserPreferenceChanged, but our application does not add this event it seams to occur when changing properties on the datagrid.
Am I correct so far. I now want to remove this system event so that the object can be dispoed, i'm currently trying to use the following code in the Dispose event but it does not appear to work
Dim eventHandler As UserPreferenceChangedEventHandler = CType(System.Delegate.CreateDelegate(GetType(UserPreferenceChangedEventHandler), mDGV, "OnUserPreferenceChanged"), UserPreferenceChangedEventHandler)
RemoveHandler SystemEvents.UserPreferenceChanged, eventHandler
mDGV is the DataGridView being referenced in the control.
Can anyone give me any advice. I need to help in VB.Net code as this is what we use for our application.
Thanks.