The first thing you need to pay attention to when you try to find memory leaks in a .NET, WPF application or not are objects that subscribe to events.
If object X listens for the event raised by object Y, then Y contains a reference to X. Regardless of which virtualization (or deletion) method you implement, if X does not cancel the subscription to the Y event, X will remain in the object for the time being until while Y does, and will never be completed and collected from the trash. (Even if it implements IDisposable , and you explicitly call Dispose on it.)
When you say that βclosing the form does not helpβ, it makes me doubly suspicious: I expect someone to inject an object property into the Window object, and this object subscribes to some event. Thus, you close the window, but it still exists in the object graph, because it refers to one of its properties.
(To give you an idea of ββhow cunning it can be: WinForms ToolStrip controls the subscription to Windows theme change events when they become visible. It's great that the theme change on your computer is automatically reflected in your user interface. It's not so great if you find ToolStrip without first setting Visible to false, it will continue to receive theme change events until the application terminates.)
A memory profiler can help with this - since I found that my application contained thousands of ToolStrip objects in memory, although I thought they were all destroyed.
source share