Reputation: 89185
I'm attempting to analyze memory usage of our Windows Phone 7 app. Querying the ApplicationPeakMemoryUsage
property yields a value of ~90Mb following a soak test. System.GC.GetTotalMemory(true)
returns ~11Mb at this time, so the balance must be unmanaged memory. The app does not explicitly allocate any unmanaged memory, so I assume the balance is GPU assets, audio and the app binary itself.
By surrounding calls to ContentManager.Load()
and GPU resource allocations (new RenderTarget2D()
, etc). with code similar to
System.GC.Collect();
unused = System.GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
long mem = ((long)Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage"));
.
. // perform loads/allocations
.
mem = ((long)Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage")) - mem;
I am able to obtain approximate figures for memory used by render buffers, texture/audio resources etc. These total ~45-50Mb across my app. ApplicationCurrentMemoryUsage
yields just under 10Mb immediately at the start of initialization. Subtracting the 11Mb managed heap as well (which is partly double-counting!), this leaves ~20Mb unaccounted for.
The Mango memory profiler tracks the totals but only breaks down allocations for the managed heap. What else might be using large quantities of unmanaged memory other than GPU resources, audio and the app binary itself? Are there any more sensible tools or methods for tracking memory than what I am doing?
Upvotes: 1
Views: 1115
Reputation: 33596
Are you using a WebBrowser control?
It has some flaws and can cause huge (and incremental) memory leaks in some scenarios, especially if the page contains many media or complicated scripts, or when its page is reloaded/changed with unlucky timing..
Upvotes: 0
Reputation: 65586
Downloaded files (including images from the web) can use lots of memory. If you're using them be sure to free up the memory again properly (see http://blogs.msdn.com/b/swick/archive/2011/04/07/image-tips-for-windows-phone-7.aspx).
Upvotes: 1