Debug Memory Counter for Windows Phone 7

September 27, 2010 22:53 by garrymc

For anyone doing any type of Windows Phone 7 development, you would have come across the debug counters that Microsoft ship, and if you' haven’t then I’d suggest checking this blog post which discusses the performance whitepaper Microsoft released.

While these counters are great and essential to any development, they do miss a few things. One of the most notable is a memory counter! This is arguably one of the most important counters to have on a memory constrained device. Also your app is only allowed to take about 80-90Meg of RAM before you’re in trouble, so you need to know this number, especially if you’re doing anything graphic intensive.

So to rectify this issue, I’ve built one which works in essentially the same way as the shipped ones. You simply add one line of code to the start up page and you’ll see the counter update every 2 seconds by default. I’ve also make it so you can specify the interval in seconds if you prefer.

MemoryCounterAs can be seen in the image it will tell you the Total Memory, Peak Memory (the most you’ve used) and the most important the current amount of memory being used.

To get this working simply add a reference to the supplied dll (see link at the end of the post) and then add the following line of code to your start-up page:

     dnp.Counter.EnableMemoryCounter = true;

If you want to specify the duration of the counter then you set it using this line of code, which specifies every 10 seconds:

     dnp.Counter.SetTimerInterval(10);

That’s it, if you’d like to leave a comment you can do so on the forums as I seem to get too much spam when I open the comments section up. You can find a forum post about this counter here.

Also, I wish to thank Stefan W. for the help he provided in getting this counter working!

 

Download: dnp.Counters.dll (37.50 kb)

kick it on DotNetKicks.com
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Currently rated 4.0 by 7 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5