Reputation: 115
I am developing a WPF MVVM (in v3.5) application using GalaSoft.MvvmLight suite and WPF Toolkit for DataGrid
and DatePicker
. However I am facing lots of memory leaks in the application every time I load a UserControl
in MainWindow
. I am trying to get the exact issue via Scitech Memory profiler, though I have some serious questions :
RelayCommand
from the Event
in VM?strings
. I don't know where they are coming from.Please help.
Upvotes: 2
Views: 3226
Reputation: 15802
Have a look at these articles to know causes of memory leaks in WPF, there solutions and how to find them -
Finding Memory Leaks in WPF-based applications:
Memory Leaks in WPF applications:
http://svetoslavsavov.blogspot.com/2010/05/memory-leaks-in-wpf-applications.html
Finding Managed Memory Leaks in WPF and Silverlight applications:
In case you are using WPF 3.5 SP1, have a look at these hot-fixes -
Memory Leak Hotfixes for WPF 3.5 SP1
http://blogs.msdn.com/b/jgoldb/archive/2010/06/14/memory-leak-hotfixes-for-wpf-3-5-sp1.aspx
Some more rare scenarios causing memory leaks -
http://blog.ramondeklein.nl/?p=58
http://code.logos.com/blog/2008/10/detecting_bindings_that_should_be_onetime.html
Upvotes: 3
Reputation: 70150
Are you certain that these are memory leaks? are you using the profiler correctly? To confirm that you have a memory leaks you must run the garbage collector so that all the objects that are not references by a stackframe are deleted. Once you have run the garbage collector inspect the heap memory for objects which should have been collected.
E.g. in your application, open a view or document, close it, garbage collector, and then check to see if it has been removed.
Upvotes: 2