Memory analysis and memory leak detection

Source: Internet
Author: User

Android


View all Process memory usage


(1) Connect the device, open the Use debug mode

(2) Open command line, execute command: adb shell Procrank


Field Description:

PID: Process ID

VSS (Virtual Set Size): Virtualized memory consumption (contains memory consumed by shared libraries)

RSS (Resident Set Size): Actual use of physical memory (contains memory consumed by shared libraries)

PSS (Proportional Set Size): Actual physical memory Used (proportional allocation of memory consumed by shared libraries)

USS (Unique Set Size): Physical memory occupied by the process alone (does not contain memory consumed by shared libraries)

CmdLine: Process Name


View heap Information


1. Open Eclipse's Ddms window and select the app you want to see

2. Click Update Heap


3. Click the Cause GC button to trigger the Java Memory Recycling mechanism, and then click to display the heap information of the process in the heap window and refresh periodically.


Field Description:

Heap Size: Total heap Memory size

Allocated: Amount of heap memory used

Free: Idle heap memory size

Used: Percentage of heap memory size used

Objects: Number of objects


Memory Leak Detection Tool (VLD)


Tools

1:https://vld.codeplex.com/releases

2:http://pan.baidu.com/s/1gd7vqnd


After the installation is complete, projects created using Visual Studio will default to include the VLD header file directory.


And the runtime in 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 usually included in the project portal file.


Here, I manually created a memory leak. Lines 10th and 12th in Map.cpp.


After the program branch ends, the dynamically allocated memory is detected without delete or free, and the information about its memory leaks is output in the Output-debug window.


This indicates that a memory leak occurred on line 10th of main.cpp, leaking 8 bytes, and clicking on the line of code that can be directly located to the memory leak. The number of memory leaks in the digital surface behind the block.


Memory analysis and memory leak detection

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.