Search code examples
c#windows-runtimewindows-phonewindows-phone-8.1background-task

Profiling memory usage of background task


I am writing a multimedia app (WP 8.1) which uses BackgroundMediaPlayer. The problem is memory - the background task quite often crashes with OutOfMemoryException. I tried going thru the code to see if there are any memory leaks, but could not find any.

I came across this article which describes memory profiling on running app - http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/03/performance-profiling-on-windows-phone-8-1-with-visual-studio.aspx How can the same be achieved for a background task? Or or there other ways to see how I can optimize memory usage of my background task?

I already tried GC.Collect as a last resort, but didn't help..


Solution

  • Install the App Field Medic, connect the Phone via USB and open the folder This PC\Windows Phone\Phone\Documents\FieldMedic\CustomProfiles in Explorer, creating missing folders in that path as needed.

    Download this profile file, copy it to CustomProfiles folder on the Phone.

    Start the Field Medic App, go to advanced, select the Multimedia Memory Profile under custom.

    enter image description here

    Now run your App, when you captured several minutes of the memory grow, go back to Field Medic, stop the trace. Copy the ETL file from This PC\Windows Phone\Phone\Documents\FieldMedic\reports to your PC and analyze it with Windows Performance Analyzer (WPA).