How can I profile the memory usage in a wp7.1 background agent?

1.2k Views Asked by At

I'm working on a scheduled background agent for Mango (7.1)

I've managed to cut my memory usage down from 10.5MB to 6.5MB using manual trace techniques based on DeviceStatus.ApplicationPeakMemoryUsage along with some intelligent guesswork about what to optimise.

However, now I need to get down to below 6MB - and the final 0.5MB is proving elusive.

I've managed to run the "Windows Phone Performance Analysis" tool on the main app, but can't seem to find a way to get it to run against the agent.

Are there any tools and/or techniques available to assist me in working out what is filling up my agent's memory? Ideally I'd like a way to investigate the entire memory space - including both code and data, and ideally it should work against a release build.

3

There are 3 best solutions below

1
On BEST ANSWER

As has already been said, the debugger will add a non-negligible memory overhead. So the best way I found is:

3
On

Remember if you are running the background agent in Debug mode this adds about 2MB onto the memory footprint of the agent, so you might be OK.

You could probably use the ApplicationPeakMemoryUsage still and write the memory details out to a file in Isolated Storage when running the app directly, rather than from Visual Studio.

HTH - Rupert.

0
On

You may find the following blog post interesting, you may have already seen it but it describes both the debug memory addition as well as some tips to decrease the memory footprint.

http://www.pitorque.de/MisterGoodcat/post/Windows-Phone-Background-Agents-Pitfalls-(2-of-n).aspx