一些查看内存状况的adb command
时间:10-02
整理:3721RD
点击:
请参考下面的1)2)3)抓取对应的信息:
1) Use adb shell cat /proc/meminfo to calculate the free memory, as usual
the free memory is MemFree + cached
taking the follow example, te free memory is 5616K + 158632K
cat proc/meminfo
MemTotal: 483724 kB
MemFree: 5616 kB
Buffers: 2732 kB
Cached: 158632 kB
SwapCached: 0 kB
Active: 277336 kB
Inactive: 83232 kB
Active(anon): 197452 kB
Attention,in the phone menu setting->apps->running app, the free memory
is MemFree + cached + background running app memory -
SECOND_SERVER_MEM,you can refer to the follwoing for details:the
function void refreshUi(boolean dataChanged)
inRunningProcessView.java(/alps/package/apps/settings/src/com/android/sett
ing/applications) (Related FAQ09452How to calculate cached free memory?)
2) Use adb shell procrank (Just ENGload) to find which process consume
most memory, please refer to PSS
adb shell procrank
PID Vss Rss Pss Uss cmdline
476 65312K 65284K 38499K 35560K com.android.launcher
268 54916K 54880K 30001K 27000K system_server
110 32196K 28988K 18924K 12432K /system/bin/surfaceflinger
347 42400K 42320K 15445K 10704K com.android.systemui
3) For the process in 2) who consume most memory, useadb shell showmap
[pid] (Just ENG load) to more details. Take system_server for example,
first get the pid by adb shell ps system_server:
adb shell ps system_server
USER PID PPID VSIZE RSS WCHAN PC NAME
system 268 111 406736 54876 ffffffff 400e9c70 S system_server
Then adb shell showmap 268 to find every .so and heap, stack memory
consume. Refer to the PSS
adb shellshowmap 268
virtual shared shared private private
size RSS PSS clean dirty clean dirty # object
-------- -------- -------- -------- -------- -------- -------- ---- ------
------------------------
72 20 20 0 0 20 0 1 /data/dalvikcache/
system@app@SettingsProvider.apk@classes.dex
352 148 103 32 16 48 52 18 /data/dalvikcache/
system@framework@android.policy.jar@classes.dex
1348 28 8 20 0 8 0 1 /data/dalvik-cache/system@php?mod=tag&id=6090" target="_blank" class="relatedlink">Framework@apachexml.
jar@classes.dex
956 60 13 52 0 8 0 1 /data/dalvikcache/
system@framework@bouncycastle.jar@classes.dex
24 8 0 8 0 0 0 1 /data/dalvik-cache/system@framework@corejunit.
jar@classes.dex
3292 1056 126 1012 0 44 0 1 /data/dalvikcache/
system@framework@core.jar@classes.dex
1) Use adb shell cat /proc/meminfo to calculate the free memory, as usual
the free memory is MemFree + cached
taking the follow example, te free memory is 5616K + 158632K
cat proc/meminfo
MemTotal: 483724 kB
MemFree: 5616 kB
Buffers: 2732 kB
Cached: 158632 kB
SwapCached: 0 kB
Active: 277336 kB
Inactive: 83232 kB
Active(anon): 197452 kB
Attention,in the phone menu setting->apps->running app, the free memory
is MemFree + cached + background running app memory -
SECOND_SERVER_MEM,you can refer to the follwoing for details:the
function void refreshUi(boolean dataChanged)
inRunningProcessView.java(/alps/package/apps/settings/src/com/android/sett
ing/applications) (Related FAQ09452How to calculate cached free memory?)
2) Use adb shell procrank (Just ENGload) to find which process consume
most memory, please refer to PSS
adb shell procrank
PID Vss Rss Pss Uss cmdline
476 65312K 65284K 38499K 35560K com.android.launcher
268 54916K 54880K 30001K 27000K system_server
110 32196K 28988K 18924K 12432K /system/bin/surfaceflinger
347 42400K 42320K 15445K 10704K com.android.systemui
3) For the process in 2) who consume most memory, useadb shell showmap
[pid] (Just ENG load) to more details. Take system_server for example,
first get the pid by adb shell ps system_server:
adb shell ps system_server
USER PID PPID VSIZE RSS WCHAN PC NAME
system 268 111 406736 54876 ffffffff 400e9c70 S system_server
Then adb shell showmap 268 to find every .so and heap, stack memory
consume. Refer to the PSS
adb shellshowmap 268
virtual shared shared private private
size RSS PSS clean dirty clean dirty # object
-------- -------- -------- -------- -------- -------- -------- ---- ------
------------------------
72 20 20 0 0 20 0 1 /data/dalvikcache/
system@app@SettingsProvider.apk@classes.dex
352 148 103 32 16 48 52 18 /data/dalvikcache/
system@framework@android.policy.jar@classes.dex
1348 28 8 20 0 8 0 1 /data/dalvik-cache/system@php?mod=tag&id=6090" target="_blank" class="relatedlink">Framework@apachexml.
jar@classes.dex
956 60 13 52 0 8 0 1 /data/dalvikcache/
system@framework@bouncycastle.jar@classes.dex
24 8 0 8 0 0 0 1 /data/dalvik-cache/system@framework@corejunit.
jar@classes.dex
3292 1056 126 1012 0 44 0 1 /data/dalvikcache/
system@framework@core.jar@classes.dex
