方式1:
通过AndroidStudio自带的Profiler工具。
方式2:
通过adb命令抓取。
adb shell am dumpheap 进程名 /data/local/tmp/test.hprof
方式3:
通过代码调用Debug.dumpHprofData()获取当前应用的heap。
var path = context?.cacheDir?.absolutePath + File.separator + "1.hprof"
Debug.dumpHprofData(path)