Memory analysis, memory leak detection, and Memory Leak Detection

Source: Internet
Author: User

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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.