1.可以使用adb shell showmap pid查看一个进程的showmap,这对于我们来说非常有用,可以确定进程中哪些库占用内存比较多
1,确定app进程号,通过jarvis过滤,ps-A显示全部进程
g6sa:/ # ps -A | grep jarvis
ps -A | grep jarvis
u0_a37 21979 2223 3858620 193980 SyS_epoll_wait 0 S cn.alios.jarvisd
u0_a47 22750 2223 3829168 172756 SyS_epoll_wait 0 S com.ebanma.jarvis
2,showmap
可以通过adb shell showmap 22750 > log7.txt?将info保存到日志里
adb shell showmap 22750
virtual shared shared private private
size RSS PSS clean dirty clean dirty swap swapPSS # object
-------- -------- -------- -------- -------- -------- -------- -------- -------- ---- ------------------------------
336 336 103 336 0 0 0 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/base.apk
44 44 44 0 0 36 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libBroadcastSignal.so
44 44 44 0 0 36 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libCarVapiSignal.so
268 268 268 0 0 252 16 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libCosmoSignal.so
96 88 88 0 0 80 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libDistributeActuator.so
592 356 356 0 0 340 16 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libLbsFenceActuator.so
164 164 164 0 0 152 12 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libLbsSignal.so
44 44 44 0 0 36 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libMapSignal.so
48 48 48 0 0 40 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libStatusActuator.so
52 52 52 0 0 44 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libStatusSignal.so
56 56 56 0 0 48 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libalios_log.so
20 20 20 0 0 12 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libatrace.so
348 244 244 0 0 228 16 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libbase.so
892 656 656 0 0 620 36 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libc++_shared.so
1904 1012 1012 0 0 848 164 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libcrypto.so
40 40 40 0 0 32 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libfreexl.so
1684 732 732 0 0 668 64 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libgeos.so
464 68 68 0 0 64 4 0 0 2 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libicudata.so
1416 724 724 0 0 680 44 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libidot.so
21960 15624 15624 0 0 15136 488 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libjarvis_engine.so
936 916 916 0 0 880 36 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libjarvis_items.so
360 352 352 0 0 336 16 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libjarvisbase.so
140 68 68 0 0 64 4 0 0 2 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libjarvisdlzma.so
1472 248 248 0 0 204 44 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libjarvisdxml2.so
88 72 72 0 0 64 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libjarvisdz.so
84 84 84 0 0 76 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libjarvisjniloader.so
168 160 160 0 0 152 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libjsoncpp.so
304 76 76 0 0 64 12 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libproj.so
32 32 32 0 0 24 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libproperties.so
1220 1136 1136 0 0 1108 28 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libsgmainso-5.4.193.so
5204 128 128 0 0 112 16 0 0 2 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libspatialite.so
1324 1160 1160 0 0 1140 20 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libsqlite3.so
164 164 164 0 0 156 8 0 0 3 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/lib/arm64/libuv.so
4 4 4 0 0 4 0 0 0 1 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/oat/arm64/base.art
72 72 72 0 0 68 4 0 0 4 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/oat/arm64/base.odex
3540 3028 3028 0 0 3028 0 0 0 1 /data/app/com.ebanma.jarvis-49tUzEJIztwJUQdjlSRzhg==/oat/arm64/base.vdex
17152 17108 1784 14300 1412 0 1396 0 0 3 /data/dalvik-cache/arm64/system@framework@boot.art
2.dumpsys meminfo分析
Applications Memory Usage (in Kilobytes):
Uptime: 11439815 Realtime: 11439815
** MEMINFO in pid 22750 [com.ebanma.jarvis] **
Pss Private Private SwapPss Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 14246 14188 0 0 20480 14419 6060
Dalvik Heap 2342 2004 0 0 3901 1951 1950
Dalvik Other 893 892 0 0
Stack 44 44 0 0
Ashmem 2 0 0 0
Other dev 13 0 12 0
.so mmap 26613 1404 23732 0
.apk mmap 383 0 12 0
.ttf mmap 23 0 0 0
.dex mmap 3926 8 3336 0
.oat mmap 910 0 0 0
.art mmap 1722 1392 4 0
Other mmap 190 4 36 0
GL mtrack 7005 7005 0 0
Unknown 1666 1628 0 0
TOTAL 59978 28569 27132 0 24381 16370 8010
App Summary
Pss(KB)
------
Java Heap: 3400
Native Heap: 14188
Code: 28492
Stack: 44
Graphics: 7005
Private Other: 2572
System: 4277
TOTAL: 59978 TOTAL SWAP PSS: 0
Objects
Views: 19 ViewRootImpl: 1
AppContexts: 5 Activities: 1
Assets: 3 AssetManagers: 0
Local Binders: 22 Proxy Binders: 31
Parcel memory: 9 Parcel count: 38
Death Recipients: 6 OpenSSL Sockets: 5
WebViews: 0
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 117
|