赞
踩
首先来看怎么使用 执行如下shell
adb shell dumpsys meminfo [包名]
假如我们要跟踪的应用包名为com.laomou.memtest 在打开应用操作一段时间后,返回到桌面 执行如下shell
adb shell dumpsys meminfo com.laomou.memtest
执行后打印控制台的结果为
pplications Memory Usage (kB):
Uptime: 27199950 Realtime: 145023102
** MEMINFO in pid 20100 [com.laomou.memtest] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 1876 1544 0 15964 29440 27821 1618
Dalvik Heap 780 740 0 36 17032 15133 1899
Dalvik Other 496 312 0 8500
Stack 136 136 0 4
Other dev 4 0 4 0
.so mmap 457 56 164 2696
.apk mmap 127 0 20 0
.dex mmap 386 44 340 4
.oat mmap 1070 0 340 0
.art mmap 1520 388 544 140
Other mmap 11 8 0 0
Unknown 92 92 0 116
TOTAL 6955 3320 1412 27460 46472 42954 3517
App Summary
Pss(KB)
------
Java Heap: 1672
Native Heap: 1544
Code: 964
Stack: 136
Graphics: 0
Private Other: 416
System: 2223
TOTAL: 6955 TOTAL SWAP (KB): 27460
Objects
Views: 7 ViewRootImpl: 0
AppContexts: 2 Activities: 1
Assets: 4 AssetManagers: 2
Local Binders: 3 Proxy Binders: 8
Parcel memory: 2 Parcel count: 10
Death Recipients: 0 OpenSSL Sockets: 0
Dalvik
isLargeHeap: false
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
Objects
查看参数,如果Views、Activities 不等于0的话,那么肯定存在内存泄漏。
Dalvik
isLargeHeap: false
AndroidManifest.xml
如果不是内存消耗大的应用,如图库之类,建议不要设置isLargeHeap=true
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。