简体   繁体   中英

WP8 Massive Memory Leaks

I'm having a real hard time with memory leaks in a fully developed app. C# with MVVM Light 5. I have spent this entire week learning how to use the memory profiler, reading up about common memory leak issues, etc, etc. I have put 25+ hours minimum into this problem. I carefully clear all event handlers, and even null out the DataContext and LayoutRoot of each page after BackNavigation, as well as when circular navigation is detected (I store the last running instance of a page in App.cs, when another instance of that page is about to be created, I check if there was already an instance and if so, I clear it).

I have exhausted my efforts and I don't know where to go from here.

Below is a link to a screenshot of the memory analysis after navigating between 2 pages repeatedly. The instances of each page are not being freed for some reason, but they ARE being reduced to mere bytes.

在此输入图像描述

As you can see, the difference between my retained allocations and retained visuals from the start and the end is very minor (about 30mb in total).

Yet in the graph, I see a difference of almost 100mb.

This is driving me absolutely crazy, I thought the underlying platform would do a better job at managing this. Any help is greatly appreciated.

I carefully clear all event handlers, and even null out the DataContext and LayoutRoot of each page after BackNavigation

I recommend that a system be put in place to re-use the VMs is done and only acquire new data if truly needed. I worked on a professional mapping application, currently in the WP store, where we only created items as needed and never created a VM twice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM