Android Memory Check

Source: Internet
Author: User

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

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.