I'm still fighting with memory leak. Using improved MemoryDiagnosticsHelper, i added possibility to make datastamps to see immediate memory cunsumption.
Problem starts at full app: i have a pivot with 3 items, 2 of them containing list of 10-20 objects (with possibility to jump to item details). Memory diagnostic shows, that it consumes about 50Mb of memory. After jumping to detail page and returning to pivot, memory consumption easily grows to 70Mb.
At first, i moved list to separate app. Without style, it takes 15 Mbs. I didnt check yet, but i assume, 2 lists in pivot would take about 20Mbs, because dlls are already loaded.
So, i decided to go deeper into app loading stage.
- At the InitializePhoneApplication(), it takes 7 Mb.
- At the CompleteInitializePhoneApplication(), it takes 8.5 Mb with empty ViewModelLocator, or 10.5 Mb with all viewmodels. Quite large, but i have 30-40 dataservices and 40-50 viewmodels. So let it be, i'd feel myself pretty ok, if it would not grow anymore.
- At the first page's OnNavigatedTo(), it takes almost the same, kinda 10.7 Mb with all VMs, that's ok.
- ???
- No profit. Seriously, what happens next? I cant see, what exactly is going on next, but MemoryDiagnosticsHelper says, that memory consumption jumps to 30 Mbs. Why? All dlls and VMs are already loaded. I'm just loading a very empty page, totally white.
Profiler (running in release mode, of course), is also helpless. It just shows growth in memory consumption, but it happens in non-managed memory. It annoys alot, really.
Ok, lets make question more clean. What happens next, when app is initialized (passed initialization, and viewmodel loaded and attached, and page passed OnNavigatedTo())?
EDIT 1: in the night, i got and idea, that the only weak part in my app (at least, that master-detail pages) is MVVMLight's EventToCommand. Almost first article in google is http://atomaras.wordpress.com/2012/04/23/solving-mvvmlights-eventtocommand-memory-leak-wp7/ Anybody knows, if it is alreasy fixed? I checked MvvmLight's blog, and looking like Laurent is working on installer for now. That pushes me to idea, that this leak should be already solved, isnt it?
EDIT 2: i see 2 solutions for leaking problem: either to use fix from the link above, or call commands from the codebehind. Or use another MVVM lib.