In the snapshots of my application I see always this message:
After some investigation I found the cause but not the solution.Undisposed instances (release resource)
One type has instances that have been garbage collected without being properly disposed.
Investigate the type below for more information.
The problem seems related to the show of a new window.
To replicate the problem it is possible to make a small project with a MainWindow with a button, in the click event I have added this code:
Code: Select all
var win = new Window1(); win.ShowDialog(); win = null;
1. Start the profiler of my application
2. Make a first snapshot without open the second window
3. Show the second window and after close it
4. Make a second snapshot and I see the "undisposed instance"
Also if I force the Garbage Collector, the object stay live.
There is a solution for this problem?
I don't have any idea on how avoid this, on internet I have found also some tricks, for example to use the API SendMessage to notify the close, but the result it is the same.