Android Studio uses the MAT analysis tool

Memory Analyzer Tool

 a brief introdction

MAT (Memory Analyzer Tool), an Eclipse-based memory analysis tool, is a fast, feature-rich JAVA heap analysis tool, which can help us find memory leaks and reduce memory consumption.

Use memory analysis tools to analyze from many objects, quickly calculate the size of the objects in memory, see who is preventing the garbage collector from recycling, and can visually view the possible results through the report Object.

Why use MAT?

When the server application takes up too much memory, it will encounter OutOfMemoryError, but the space cannot be reclaimed, causing memory leaks,
java server system exceptions, such as high load, io exception, or thread deadlock, etc., which may be detected by analyzing the heap The appearance of
Eclipse MAT makes this problem very simple. It can analyze dump file data offline.
Eclipse MAT is a tool contributed by SAP, which can be downloaded from the Eclipse website, completely free of charge.

Download link: Eclipse Memory Analyzer Open Source Project | The Eclipse Foundation

 

Already reached version 1.14.0

Students who use Eclipse can install the mat plug-in in Eclipse

The Update Site in the picture is the plug-in address: http://download.eclipse.org/mat/1.7/update-site/

Initial interface:

 

An error encountered when using the MAT tool to analyze the file

Today I will mainly introduce an error I encountered when using the MAT tool to analyze files

Error opening heap dump 'a.hprof'. Check the error log for further details.
Error opening heap dump 'a.hprof'. Check the error log for further details.
Unknown HPROF Version (JAVA PROFILE 1.0.3) (java.io.IOException)
Unknown HPROF Version (JAVA PROFILE 1.0.3)

The reason is: the format of the memory file hprof exported by the android virtual machine is different from the standard java hprof file format. The fundamental reason is that the virtual machines of the two are inconsistent.

Just use the conversion tool that comes with the SDK to convert

The first hprof file is the one you get from AS and needs to be converted, and the second one is named by you; 

Open MAT

 Importing files

An import error occurred, how to solve it next?

Just use the conversion tool that comes with the SDK to convert

The previous reasons have been mentioned, and you can see it when you operate it. For better operation, we take a screenshot

 Then


The hprof-conv command uses the new file path of the hprof-conv source file like this 

Import the a.hprof file and it will be successful

Click Finish to generate the report

For specific usage methods, please refer to

Android memory performance optimization (recommended) - Big Fisherman's Blog - CSDN Blog

"Three Optimization Directions" of Android Memory Optimization - Programmer Sought

Guess you like

Origin blog.csdn.net/gqg_guan/article/details/130262445