9

使用MAT比较多个heap dump文件

 3 years ago
source link: http://yuanfentiank789.github.io/2017/12/26/%E4%BD%BF%E7%94%A8MAT%E6%AF%94%E8%BE%83%E5%A4%9A%E4%B8%AAheap-dump%E6%96%87%E4%BB%B6/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

使用MAT比较多个heap dump文件

调试内存泄露时,有时候适时比较2个或多个heap dump文件是很有用的。这时需要生成多个单独的HPROF文件。

下面是一些关于如何在MAT里比较多个heap dumps的内容(有一点复杂):

1.     第一个HPROF 文件(usingFile > Open Heap Dump ).

2.     打开Histogram view.

SouthEast

图1. Histogram View按钮

3.     在NavigationHistory view里 (如果看不到就从Window > Navigation History找 ), 右击histogram然后选择Add to Compare Basket .

4.     打开第二个HPROF 文件然后重做步骤2和3.

5.     切换到Compare Basket view, 然后点击Compare the Results (视图右上角的红色"!"图标)。

SouthEast

图2. 对比分析结果

         如上,结果图中,Objects #1所代表的weak.create.hprof比Objects#0所代表的main.hporf多出了一个WeakReferencesActivity;Objects #2更是多出10000个WFObject对象出来,结果很明显。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK