Android Memory Check
This article briefly describes how to use the DDMS and MAT tools to check Android memory for specific usage of Android memory.
Step 1. Use DDMS to observe memory usage
Environment Preparation: The computer installed the Android SDK, the mobile phone has turned on the USB debugging switch, the phone connected to the PC.
You can use DDMS alone, or in Android Studio, tools---Android device Monitor, to choose which device and process to debug.
Step 2. Memory usage exception when dump HPROF files
Under normal circumstances, the allocated size value will stabilize within a limited range, and will be released after each GC, if it is found that the allocated size has been increased without being released, indicating a problem with memory consumption and possibly a memory leak. Click on the dump Java heap on the left to export the Hprof file, assuming the name is test.hprof.
Step 3. Analyze hprof files using the MAT
(1) First download the Mat tool, the mat can be an Eclipse plugin, or you can download a standalone app.
MAT Tool: http://www.eclipse.org/mat/downloads.php
(2) The Hprof file exported in step 2 cannot be parsed directly by MAT and needs to be converted:
CMD into the Sdk\tools directory, such as: CD E:\AutoTestProj\AutoTest\tools\android_sdk\tools;
(3) Copy the test.hprof exported from step 2 to the directory;
(4) Run Cmd:hprof-conv test.hprof output.hprof
The Output.hprof file is generated under this directory;
(5) Mat tool import Hprof file
File, open heap dump, select Output.hprof, you can see the leak suspects analysis report. If the problem is found, it needs to be solved in time and development communication.
Android Memory Check