Android 内存泄露分析之MAT工具分析

工具mat. eclipse memory analyzer

1.转换为标准hprof
hprof-conv -z in. hprof  out.hprof  //hprof-conv sdk下面的工具

2. mat打开out.hprof

3.查看Leak Suspects,大概是泄露在哪里,不过一般没什么价值

4.点击histogram图标(左边第二个图标)
5.查看那种最多,比如app一般搜索PhoneWindow,可以看到有多少泄露。假如很多的话就证明就是这里发生内存泄露,

6.选择右键list objects-- with incoming reference,会看到这些窗口是来至于哪里

7.选择右键path to gc roots -- exclude all platform/ weak/ soft etc references 看到gc过程可以看到是什么对象没有回收导致泄露

8.使用OQL ( open object query language)
查询对象泄露的个数,比如
select * from com. android. settings. Settings$NetworkDashboardActivity,上面有个感叹号图标执行搜索F5

猜你喜欢

转载自blog.csdn.net/wd229047557/article/details/83897838