Android:mat Use of memory analysis tools

Source: Internet
Author: User

Objective

have seen this blog before, "IBM use Eclipse Memory Analyzer for heap dump file analysis. So, you want to use mat to analyze the memory of the Android app. And just see this blog "Android Memory leak research", so I also summed up some of the use of mat.

1. Install Mat on Eclipse, same as installing other plugins, the current address of mat: http://download.eclipse.org/mat/1.4/update-site/Installation


Restart eclipse when you're done.


2. On the device page, select the app,1 that corresponds to the package name. Click on the icon and wait for a while and the results of Figure 2 will appear.



Figure 1




Figure 2


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


View the number of objects and the amount of memory consumed.




Figure 3


The object shown in Figure 3 can display up to 31, but we can filter it based on the package name and the class name. Most importantly, we can right-click to view


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





Figure 4




Figure 5


As you can see, the activity is referenced by the path. As you can see, the activity has already been completed, but Gifview still retains its reference, resulting in the inability to GC.


Again, we can analyze the objects that take up the most memory and then look at their reference tree. Note: Not all objects that take up more memory will


Cause a memory leak. For example, a larger picture, when it needs to be displayed, it is clear that its corresponding byte array should appear in memory.




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

more communication, Android Development Alliance QQ Group: 272209595





Android:mat Use of memory analysis tools

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.