Over a million developers have joined DZone.
Platinum Partner

Windows Phone Performance tips: Monitoring the memory usage

· Mobile Zone

The Mobile Zone is brought to you in partnership with Strongloop and IBM.  Learn how IBM API Connect simplifies your API lifecycle for hybrid cloud with Node.js and Java.

The default Windows Phone emulator offers plenty of ways to monitor your application's performance, but in this quick tip you'll learn how to monitor the total memory usage of your application when your emulator can't.

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):

   1: 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:

   1: MemoryDiagnosticsHelper.Start(true);

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

image


Source:  http://mikaelkoskinen.net/post/wp7-performance-tip-monitoring-memory-usage.aspx

The Mobile Zone is brought to you in partnership with Strongloop and IBM.  Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud.

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}