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.
As 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:
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)
Its been awhile since I put up a blog post and that’s partly due to being so busy working on my two Windows Phone 7 Apps. Which brings me to the topic of this post and one which I think is important for fellow devs to understand. I am one of the lucky few that have received a real device and its very nice! :) (thanks Microsoft!)
One of the first things I started to do was performance test my App on the device and found that the device is a lot slower than the emulator. So I started to run some optimizations and wrote a small benchmark App to help me work out which refactorings were the fastest. I was rather pleased with myself when I ended up getting improvements of 200 and 300%! in the emulator. Then thought I’d see how much of that new gain transferred to the device. The results shocked the hell out me, as rather than getting a gain I ended up with a lost of 50%! That’s right my optimizations did the exact opposite of what they were supposed to do.More...
While I don't normally get involved with deploying web applications (we normally have 'people' for that) however I did have to deploy the application you're using now. Which brings me to the blog post I recently found which discusses the top 10 best practices for ASP.NET which I've linked to on my toolbox page. The main one that concerned was of concern to me was forgetting to switch off debug mode.
2: <compilation debug="false" />
This setting appears to have a large impact on production web sites so I'd check out the detail in the this post to get all the details. Also you might want to check the config files of the production apps you work on or blog if you host your own; lets just say we may need to update a few of ours!