Windows Phone 7 Navigation Memory Usage Just Got Scary

In my previous post I showed a couple of graphs of memory usage with some basic pages within a Windows Phone 7 application. Now I’ve started adding some content to the pages. First up I’ve added a single button to the second page:

<phone:PhoneApplicationPage x_Class="OptimisePerformance.SecondPage"

– 2 Pages w Button (iterative): Iterative navigation between the MainPage and the second page every approx 6 seconds.

– 2 Pages w Button (iterative) (GC): Same again but this time GC.Collect is called before retrieving memory usage information

Now this is somewhat scary. Notice that when GC.Collect is called the memory usage is pretty much as you would expect. As you navigate to a page, memory usage goes up; As you go back to the MainPage the memory is reduced; Overall no memory usage increate. Unfortunately this is not the case if you don’t call GC.Collect. It appears that memory usage (both max and current) progressively increases over time. It does kind of hit a ceiling but it’s significantly higher than even the memory usage when the second page is displayed.

This backs up my previous post when I hinted that you may want to selectively call GC.Collect to free up memory.

**Note: I’m not sure what the sudden drop in the current memory usage for when GC.Collect wasn’t being called. This is probably just an anomaly of the way the data is being recorded.

Leave a comment