Memory analysis, memory leak detection, and Memory Leak Detection
Android
View memory usage of all processes
(1) connect the device and enable the USE debugging mode.
(2) Open the command line and execute the command: adb shell procrank
Field description:
PID: process id
VSS (Virtual Set Size): Virtual memory consumption (including the memory occupied by the Shared Library)
RSS (Resident Set Size): the actual use of physical memory (including the memory occupied by the Shared Library)
PSS (Proportional Set Size): physical memory actually used (Proportional allocation of memory occupied by the Shared Library)
USS (Unique Set Size): physical memory occupied by the process (excluding the memory occupied by the Shared Library)
Cmdline: process name
View Heap Information
1. Open the DDMS window of Eclipse and select the application to be viewed
2. Click Update Heap.
3. Click the Cause GC button to trigger the Java memory recycle mechanism. After clicking this button, the Heap information of the process is displayed in the Heap window and refreshed regularly.
Field description:
Heap Size: Total Heap memory Size
Allocated: used heap memory size
Free: idle heap memory size
Used: Percentage of Used heap memory size
Objects: number of Objects
Related Articles: Android best performance practices (2)-Analysis of memory usage
Memory leakage detection tool (VLD)
Tools
1: https://vld.codeplex.com/releases
2: http://pan.baidu.com/s/1gd7vQnD
After the installation is complete, the project created using visual studio contains the vld header file directory by default.
In addition, the Runtime library under the bin directory has been automatically added to the Path variable.
All we need to do is # include <vld. h> in the source code, which is generally included in the project entry file.
Here, I manually created a memory leak. In the rows 10th and 12th of map. cpp.
After the Program Sub-branch is completed, it is detected that the dynamically allocated memory is not deleted or free. In the output-Debug window, information about memory leakage will be output.
The following message is displayed: Memory leakage occurs in line 3 of main. cpp, with 8 bytes leaked. You can click the line of code that directly locates the memory leakage. Memory leakage at the number of digits following the Block.