Total RAM: 2,822,140K
Free RAM: 559,338K ( 201,658K cached pss + 314,512K cached kernel + 43,168K free)
Used RAM: 2,054,592K ( 901,044K used pss + 1,153,548K kernel)
Lost RAM: 287,420K
ZRAM: 20,608K physical used for 89,492K in swap ( 524,284K total swap)
1, Free RAM: 559,338K ( 201,658K cached pss + 314,512K cached kernel + 43,168K free)
1.1 201,658K cached pss: cachedPss
201,658K: Cached \( 70,462K in swap\)
61,029K: com.android.settings \(pid 11388 / activities\) \( 26,287K in swap\)
32,387K: org.codeaurora.gallery \(pid 11579 / activities\) \( 6,150K in swap\)
24,533K: com.android.email \(pid 11638 / activities\) \( 7,113K in swap\)
15,887K: com.android.browser \(pid 10215\) \( 2,914K in swap\)
15,718K: com.android.packageinstaller \(pid 11682 / activities\) \( 5,248K in swap\)
10,596K: com.android.calculator2 \(pid 11486 / activities\) \( 5,112K in swap\)
7,514K: com.android.deskclock \(pid 5892\) \( 2,785K in swap\)
5,704K: com.android.calendar \(pid 732\) \( 2,200K in swap\)
5,130K: com.android.providers.calendar \(pid 830\) \( 2,080K in swap\)
4,223K: com.android.defcontainer \(pid 30891\) \( 1,917K in swap\)
4,190K: com.qualcomm.qti.calendarwidget \(pid 773\) \( 1,762K in swap\)
3,970K: com.qualcomm.qti.accesscache \(pid 2604\) \( 1,731K in swap\)
3,860K: com.android.musicfx \(pid 21631\) \( 1,794K in swap\)
3,527K: com.svox.pico \(pid 21688\) \( 1,714K in swap\)
3,390K: com.qualcomm.timeservice \(pid 919\) \( 1,655K in swap\)
1.2 314,512K cached kernel: getCachedSizeKb()
public long getCachedSizeKb\(\) {
return mInfos\[Debug.MEMINFO\_BUFFERS\]
+ mInfos\[Debug.MEMINFO\_CACHED\] - mInfos\[Debug.MEMINFO\_MAPPED\];
}
注:page cache比较特殊,很难区分是属于kernel还是属于进程,其中被进程mmap的页面自然是属于进程的了,而另一些页面没有被mapped到任何进程,那就只能算是属于kernel了。
1.3 3,168K free: getFreeSizeKb()
public long getFreeSizeKb\(\) {
return mInfos\[Debug.MEMINFO\_FREE\];
}
2, Used RAM: 2,054,592K ( 901,044K used pss + 1,153,548K kernel)
2.1 901,044K used pss : totalPss-cachedPss
totalPss: 1102702KB
cachesPss: 201658KB
used pss = 1102702KB-201658KB = 901044KB
Total PSS by OOM adjustment:
319,612K: Native \( 536K in swap\)
85,508K: System \( 0K in swap\)
174,078K: Persistent \( 0K in swap\)
75,227K: Foreground \( 4,556K in swap\)
12,931K: Visible \( 0K in swap\)
10,264K: Perceptible \( 0K in swap\)
39,178K: Home \( 0K in swap\)
146,334K: Previous \( 10,060K in swap\)
37,912K: B Services \( 14,740K in swap\)
201,658K: Cached \( 70,462K in swap\)
319612+85508+174078+75227+12931+10264+39178+146334+37912+201658 = 1102702
* 进程所占的内存页分为anonymous pages和file-backed pages,理论上应该有:
【所有进程的PSS之和】 == 【Mapped + AnonPages】。
536+4556+10060+14740+70462 = 100354
TotalSwapPss = 100354
2.2 1,153,548K kernel : getKernelUsedSizeKb()
public long getKernelUsedSizeKb() {
return mInfos[Debug.MEMINFO_SHMEM] + mInfos[Debug.MEMINFO_SLAB]
mInfos\[Debug.MEMINFO\_VM\_ALLOC\_USED\] + mInfos\[Debug.MEMINFO\_PAGE\_TABLES\]+
mInfos[Debug.MEMINFO_KERNEL_STACK];
}
nr\_free\_pages 8943
nr\_alloc\_batch 56
nr\_inactive\_anon 34639
nr\_active\_anon 121086
nr\_inactive\_file 78858
nr\_active\_file 76121
nr\_unevictable 64
nr\_mlock 64
nr\_anon\_pages 151415
nr\_mapped 66787
nr\_file\_pages 160733
nr\_dirty 9
nr\_writeback 0
nr\_slab\_reclaimable 162976
nr\_slab\_unreclaimable 90398
nr\_page\_table\_pages 8097
nr\_kernel\_stack 1770
nr\_unstable 0
nr\_bounce 0
nr\_vmscan\_write 48935
nr\_vmscan\_immediate\_reclaim 2
nr\_writeback\_temp 0
nr\_isolated\_anon 0
nr\_isolated\_file 0
nr\_shmem 4378
nr\_dirtied 1896707
nr\_written 1945440
nr\_pages\_scanned 0
workingset\_refault 19802
workingset\_activate 6062
workingset\_nodereclaim 0
nr\_anon\_transparent\_hugepages 0
nr\_free\_cma 49
nr\_swapcache 1376
3, Lost RAM: 287,420K
long lostRAM = memInfo.getTotalSizeKb() - (totalPss - totalSwapPss)
memInfo.getFreeSizeKb\(\) - memInfo.getCachedSizeKb\(\)
memInfo.getKernelUsedSizeKb\(\) - memInfo.getZramTotalSizeKb\(\);
= 2,822,140K- (1102702KB- totalSwapPss)-43,168K-314,512K -1,153,548K-20,608K
= 187602K+totalSwapPss
*SwapPss is the PSS memory not having being accessed recently and being swapped out
of memory.