Stuart
Stuart

Reputation: 66882

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

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.

Upvotes: 4

Views: 1219

Answers (3)

Kevin Gosse
Kevin Gosse

Reputation: 39047

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

Upvotes: 5

Paul Diston
Paul Diston

Reputation: 3294

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

Upvotes: 0

Rupert
Rupert

Reputation: 516

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.

Upvotes: 1

Related Questions