Android: Use of MAT memory analysis tools, androidmat

Source: Internet
Author: User

Android: Use of MAT memory analysis tools, androidmat

Preface

I have read this blog, "using Eclipse Memory Analyzer to analyze heap dump files". Therefore, we want to use MAT to analyze the memory of the android app. I just saw this blog "Android Memory leakage research", so I also summarized some usage of MAT.

1. Install MAT on Eclipse, the current address of MAT: http://download.eclipse.org/mat/1.4/update-site/ installation, just like installing other plug-ins


After that, restart Eclipse.


2. on the device page, select the app corresponding to the package name. 1. Click the icon and wait for a while. The analysis result shown in Figure 2 is displayed.



Figure 1




Figure 2


Based on the analysis results, we can see the memory usage of the app. Click Histogram on the action tab in the lower left corner to use the Histogram.


View the number of objects and the memory size.




Figure 3


As shown in figure 3, up to 31 objects can be displayed, but we can filter them based on the package name and class name. Most importantly, you can right-click to view


Which objects are referenced by the object, so that we can analyze the reason why the object is not GC, and then check the corresponding code.





Figure 4




Figure 5


We can see that the URL of the Activity is referenced. It can be seen that although the Activity has been completed, GifView still saves its reference, resulting in GC failure.


Similarly, we can analyze the objects with the most memory available for the moment, and then view their reference tree. Note: not all objects with a large amount of temporary memory will


Memory leakage. For example, when a large image needs to be displayed, it is clear that its corresponding byte array should appear in the memory.




-------------------------------------------------------------------

For more information, the Android Development Alliance's QQ group: 272209595





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.