1. Use Android Studio's built-in Android Profiler to generate hprof files
打开Android Profilter(View -> Tool View -> Android Filter)
2. Convert the hprof file to a standard format that mat can recognize, and open the command line: hprof-conv hprof_path standard_hprof_path
3. Use mat to open the generated standard_hprof file
4. Open the Histogram view.
5. In the NavigationHistory view (if you can't see it, find it from Window > Navigation History), right click on the histogram and select Add to Compare Basket.
6. Open the second HPROF file and redo steps 1 and 5
7. Switch to the Compare Basket view, then click Compare the Results (the red "!" icon in the upper right corner of the view).
As above, in the result figure, the weak.create.hprof represented by Objects #1 has one more WeakReferencesActivity than the main.hporf represented by Objects#0; Objects #2 has 10,000 more WFObject objects, and the result is obvious.
Reference: https://blog.csdn.net/sodino/article/details/38513067