Debug Windows PhoneProgramWe usually need to know how much memory is occupied by the current program and whether there is any memory leakage.
In the previous Windows Phone 7 tips (5), we mentioned that enableframeratecounter is used to monitor the frame rate when the program is running. The usage is as follows:
// Show graphics profiling information while debugging. if (system. diagnostics. debugger. isattached) {// display the current frame rate counters. application. current. host. settings. enableframeratecounter = true;
}
The following is a detailed explanation of the toolbar on the right.
There is no memory usage we want to see here. How can we do this. There is such a class in Windows Phone Microsoft. Phone. info. deviceextendedproperties The memory usage is provided. The specific attributes are as follows:
Attribute Value |
Return Value |
Description |
Devicetotalmemory |
Long Integer |
Total device memory (in bytes) |
Applicationcurrentmemoryusage |
Long Integer |
Current application memory usage (in bytes) |
Applicationpeakmemoryusage |
Long Integer |
Maximum Application Usage (in bytes) |
You may need to write the followingCodeTo view the data
Of course, there is also a simpler method, that is, to introduce a DLL (DLL download), and then write a few pieces of code to complete the process.
DNP.Counter. Enablememorycounter =True;
The default refresh interval is 2 seconds. Of course, you can set the refresh interval by yourself.
DNP.Counter. Settimerinterval (1 );
Reference
Http://blogs.msdn.com/ B /mikeormond/archive/2010/12/16/monitoring-memory-usage-on-windows-phone-7.aspx
Http://dotnetprofessional.com/blog/post/2010/09/27/Debug-Memory-Counter-for-Windows-Phone-7.aspx