WindowsFormsHost hanging in memory after Dispose
-
2012년 8월 15일 수요일 오후 1:13
I've created a WindowsFormsHost to host an ActiveX control, and the WindowsFormsHost still hangs in memory even after I've called Dispose() and removed it from the canvas. Even if I don't create an ActiveX child, the control stays in memory. Each time I create one, the old ones hang around even if I force a garbage collection.
I ran a utility called "JustTrace", and it says that the WindowsFormsHost is being held by System.Windows.Interop.HwndSourceKeyboardInputSite. I also tried using reflection to get the underlying winFormsAdapter and using Dispose on that object, but it doesn't help.
Is there something else that I need to do in order to get the WindowsFormsHost objects cleaned up?
모든 응답
-
2012년 8월 17일 금요일 오전 9:11중재자
Hi Magneto1,
Do you also clear the reference of the widnowsFormsHost and unsubscribe from events that are outside of your scope, i.e. that are members of objects that will stay alive? You can refer to below links for your reference:
http://stackoverflow.com/questions/2047012/i-want-my-memory-back-how-can-i-truly-dispose-a-control
And here is a link that contain much memory leak situation in WPF for your reference:http://blogs.msdn.com/b/jgoldb/archive/2008/02/04/finding-memory-leaks-in-wpf-based-applications.aspx
Hope it helps.
Have a nice day.
Annabella Luo[MSFT]
MSDN Community Support | Feedback to us
- 답변으로 표시됨 Annabella LuoModerator 2012년 8월 28일 화요일 오전 10:09
-
2012년 8월 28일 화요일 오전 10:10중재자
Hi Magneto1,
Have heard from you for more than a week, so I'm temporarily marking this as "Answer", if you have any concerns or new findings; please feel free to let me know.
Best regards.Annabella Luo[MSFT]
MSDN Community Support | Feedback to us

