1. 取消勾选
image.png
2. profile app
image.png
3 双击 Memory
image.png
4. 打开某个APP页面 ,查看内存是否增加
image.png
查看内存是否抖动,下图表示有很多垃圾回收操作
image.png
5. 选择区间,选择“Allocation” 进行排序
image.png
image.png
新版 AndroidStudio
image.png
image.png
如果停止了
image.png
6. 某个页面 dump 内存
image.png
新版本 AndroidStudio
image.png
跳转其他页面一顿操作, 返回到之前的页面 再 dump一次 ,生成两个 profile文件, 执行 hprof 命令 转换成 MAT能识别的 hprof 文件
hprof-conv 1.hprof 1-conver.hprof
在MAT 里面同时选中两个文件, 选择 Historgram,在 2.hprof 里 操作对比按钮,选择 1. hporf
image.png
- 【+】号表示 新增对象
-
【-】号表示 减少对象
image.png
发现 2.hprof 多了几个 Activity,在 2.hprof 页面点击按钮,查看多余 Activity 信息
image.png
image.png
image.png
image.png
7. AndroidStudio 抓取内存泄漏
一顿操作后 , 执行 dump hprof
image.png
image.png
8. 强制垃圾回收
image.png
image.png
image.png