Android内存管理(7)在AS中查看内存和cpu情况
Memory and CPU monitor
Android Studio provides a memory and CPU monitor view so you can more easily monitor your app's performance and memory usage to track CPU usage, find deallocated objects, locate memory leaks, and track the amount of memory the connected device is using. With your app running on a device or emulator, click the Android tab in the lower left corner of the runtime window to launch the Android runtime window. Click the Memory or CPU tab.
Figure 4. Monitor memory and CPU usage.
Heap dump
When you're monitoring memory usage in Android Studio you can, at the same time, initiate garbage collection and dump the Java heap to a heap snapshot in an Android-specific HPROF binary format file. The HPROF viewer displays classes, instances of each class, and a reference tree to help you track memory usage and find memory leaks.
Figure 5. HPROF viewer with heap dump.
To create a snapshot of the Android app heap memory, click the Dump Java Heap icon () in the Memory Monitor. Android Studio creates the heap snapshot file with the filename Snapshot-yyyy.mm.dd-hh.mm.ss.hprof
in the Captures tab. Double-click the heap snapshot file to open the HPROF viewer.
To convert a heap dump to standard HPROF format in Android Studio, right-click a heap snapshot in the Captures view and select Export to standard .hprof.
Allocation tracker
Android Studio allows you to track memory allocation as it monitors memory use. Tracking memory allocation allows you to monitor where objects are being allocated when you perform certain actions. Knowing these allocations enables you to adjust the method calls related to those actions to optimize your app's performance and memory use.
Figure 6. Allocation tracker.
For information about tracking and analyzing allocations, see Memory Monitor.
最新文章
- POJ 1061 同余方程
- WeX5之xid相关API
- 三维网格形变算法(Linear rotation-invariant coordinates和As-Rigid-As-Possible)
- zepto源码--isEmptyObject,isNumeric,inArray,trim--学习笔记
- [AIR] Screen 的应用
- sqlplus handbook
- 创建android 模拟器并在cmd中打开
- javascript . 05 json的组成、for...in 遍历对象、简单数据类型与复杂数据类型的传值与传址、内置对象
- perl多线程使用
- 基于Odoo框架的开源在线客服系统
- 什么是HTML DOM对象
- (转)Spring Boot (十四): Spring Boot 整合 Shiro-登录认证和权限管理
- jxl和POI的区别
- ImportError: No module named 'xml'
- 工控机安装Ubuntu14.04
- css 元素选择器实例
- es6 let关键字
- MySQL5.7.24安装笔记
- 【bzoj3295】[Cqoi2011]动态逆序对 树套树 线段树套替罪羊树
- SVM之核函数