Advanced debugging advice in WPF GarbageCollection Advanced debugging advice in WPF GarbageCollection wpf wpf

Advanced debugging advice in WPF GarbageCollection


I have the same issue with one of my applications. On every opening of a window I call:

GC.GetTotalMemory(true);

This will force GC to clean the memory immediately without waiting. You can read more about this method here:

http://msdn.microsoft.com/en-us/library/system.gc.gettotalmemory.aspx

About the problem with the calls to CanExecute, I try to avoid them because of the same performance problems. Instead, I use properties in my view model and bind the IsEnabled property of the visual elements from XAML to the properties from the view model. In this way, the overall performance is improved and the CanExecute calls are gone.

I hope this will help.


Try CLRProfiler, here's the downloading link. It shows the event handlers allocated, disposed and survived. I am sure you can trace to the root cause by using this tool.The book Advanced .NET Debugging lists some good tools for debugging, you can read it for some help.