Applications, even for smartphones, can perform operations that intensively use resources. For this reason, it is possible that an application behaves differentially on various devices. This could lead to some problems with the operation, such as a poor user experience. With the usage of Microsoft Visual Studio Community 2015, a developer could measure CPU and memory usage in real time while running the application. In this recipe, you will learn how to use such a mechanism in your projects.
To monitor the CPU and memory usage while debugging the application, you need to perform the following steps:
Start debugging the application.
Open the Diagnostic Tools window by navigating to Debug | Show Diagnostic Tools from the menu.
Observe the process memory and CPU usage in charts, shown as follows:
The Diagnostic Tools window presents a set of useful information, not only about the used MB of the memory and percentage of CPU used. It also informs about moments when Garbage Collector (GC) is launched. What is more, you can see some steps of debugging, such as hitting a breakpoint.
It is really important to check the execution of the application on the slowest supported device to ensure that it will not have any problems with performance. Reaching the maximum acceptable values of CPU or memory usage is a sign that the code needs to be optimized. By modifying the code and checking its performance in an iterative way, you will see the impact of your changes on the final result.