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