I'm currently working on a WPF-based application that allows a User to open multiple instances of a WinForms graphical control in a TabControl. The WinForms control is wrapped in a WinFormsHost-based UserControl.
For some reason, instances of the UserControl are not being released when their associated tab is closed. I've spent the better part of a day using a demo copy of .NET Memory Profiler trying to determine the root cause. From what I can tell, the problem seems to revolve around the WinFormsAdapter that contains my User Control, but I can't quite see my way through the trees.
If anyone could take a look at my saved session and give me a push in the right direction, that'd be great.
To create the session, I:
- Started my app
- Opened a single copy of my User Control in a tab
- Closed the tab
- Took snapshot #1
- Opened a new instance of my User Control
- Closed the tab
- Took snapshot #2
Comparing the snapshots, I can see that there are now 2 instances of my User control in memory. This scenario can be repeated to create additional (leaked) copies of the control.
In the referenced profiler session, the control is in the "CustomControls" namespace and is named "ViewportCustomUC".
The snapshot is here: https://www.dropbox.com/s/xz554acush2ba ... prfsession
Thanks for any assistance you can provide.
Jeff