Android学习-Android Studio Profiler

650 阅读1分钟

打开 Profile

如需打开 Profiler 窗口,请依次选择 View > Tool Windows > Profiler,或点击工具栏中的 Profile 图标 

image.png

打开Profile 把项目运行起来。 就可看到以下内容 image.png

如果没有可以自行添加:

image.png

在你对应用进行操作的时候就会看到时间轴上的CUP和MEMORY产生波动。

image.png

内存泄露分析

点击内存一栏。

image.png image.png image.png image.png

这个MyFragment就是所在页面。这样可以根据内存使用类,定位到使用位置。

CPU性能分析。

首先修改配置

image.png image.png

然后 -> Apply -> OK

点击CPU一栏

image.png

选择 System Trace Recording 然后 点击Record 开始录制。

image.png

录制一段时间后点击 Stop 。
稍等一点时间会出现以下页面:

image.png

然后 用鼠标左键拉取一定范围。

image.png

这样就可在右侧 name 栏里看到那些类占用了CUP。