Android App Memory Leak Debug Tool (1)

Source: Internet
Author: User



Android App Memory Leak tool (1) using the Memory Monitor tool ddms–> Heap

Operation Steps

  1. After you start eclipse, switch to the DDMS perspective and make sure that the devices view, the heap view, are open, and that you do not open the direct window>showview>

  2. Link your phone to your computer via USB. The link needs to confirm that the phone is in "USB Debug" mode

  3. After the link is successful, the serial number of the mobile device will be displayed in the Devices view of the DDMS, along with the part of the process information that is being performed on the device;

  4. Click to select the process you want to monitor, and if you don't see your process in the list of processes, select one of the tools that make the device row available. Then hit the update Heap and let itself proactively find the process of the app we ran. For example, the pony's two application processes for a temporary run.

  5. Click on the "Cause GC" button in the heap view;

  6. When you click Cause GC, you can see the memory of our app, for example, by:

Description

1 Click the "Cause GC" button to request a GC operation to the virtual machine

2 When the memory usage information is displayed for the first time, no more pressing "cause GC"

Heap视图界面会定时刷新,在相应用的不断的操作过程中就能够看到内存使用的变化

3 memory usage information by name you can know its meaning, do not know the details of the meaning of the friends themselves with tools (Youdao, Word bully)

知道工具使用了。那么怎样才干知道我们的程序是否有内存泄漏的可能性呢。这里须要注意一个值:Heap视图中部有一个Type叫做data object,即数据对象,也就是我们的程序中大量存在的类类型的对象。

在data object一行中有一列是“Total Size”,其值就是当前进程中全部Java数据对象的内存总量。假设大家想要看“Total Size”是分配的具体信息能够点击“data object这一行来查看具体信息,例如以”(大家看不清楚的点击看大图)

In general, the size of the value "total size" on the data object line determines if there is a memory leak.

Can infer that:

 a) 不断的操作当前应用,同一时候注意观察data object的Total Size值。 b) 正常情况下Total Size值都会稳定在一个有限的范围内。也就是说因为程序中的的代码良好,没有造成对象不被垃圾回收的情况,    所以说尽管我们不断的操作会不断的生成非常多对 象,而在虚拟机不断的进行GC的过程中。这些对象都被回收了,    内存占用量会会落到一个稳定的水平; c) 反之假设代码中存在没有释放对象引用的情况,则data object的Total Size值在每次GC后不会有明显的回落。    随着操作次数的增多Total Size的值会越来越大。直到到达一个上限后导致进程被杀掉。

Please follow my GitHub.


Android App Memory Leak Debug Tool (1)

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.