Mobile Zone is brought to you in partnership with:

Mikael is the founder of Adafy Oy, a Finnish software startup providing development services for Windows Phone, Windows 8 and Windows Azure. Adafy is available for hire: Mikael is a DZone MVB and is not an employee of DZone and has posted 46 posts at DZone. You can read more from them at their website. View Full User Profile

WP7 Performance tips: Monitoring the memory usage

  • submit to reddit

Out of the box the WP7 emulator offers a way to monitor some performance aspects of a WP7 app by providing the following counters:

  • Render thread FPS
  • User interface FPS
  • Texture memory usage
  • Surface counter
  • Intermediate texture count
  • Screen fill rate

The counters are turned on by default and can be manually turned off by removing the following line in App.xaml.cs (or by changing the flag to false):

Application.Current.Host.Settings.EnableFrameRateCounter = true;

Jeff Wilcox has a great article about the different performance counters and it can be reached from his blog.

What is missing from the emulator is a way to monitor the total memory usage of your application. WP7 app shouldn’t use more than 90MBs of RAM so monitoring the mem usage is crucial. Thankfully, Peter Torr comes to the rescue. He has published a class called MemoryDiagnosticsHelper which adds a total memory usage counter to the application. It’s really easy to use and it blends nicely with the built-in performance counters.

To use the MemoryDiagnosticsHelper, first download it from the Peter’s site. Add the class into your project and then add the following line in your App.xaml.cs, just after the line where the EnableFrameRateCounter is set:


And that’s all that is required. Now you can start your application and see the total memory usage.



Published at DZone with permission of Mikael Koskinen, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Schlacter Adam replied on Sat, 2012/04/14 - 1:43am

Nice Post. I like it lot. The memory tool does not appear for us in the line of debug text. We have followed your instructions, and it simply does not appear on screen. I have also found others having this same problem.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.