Linux smaps接口文件结构
在Linux内核 2.6.16中引入了一个系统内存接口特性,这个接口位于/proc/$pid/目录下的smaps文件中,一看内容发现是进程内存映像信息,比同一目录下的maps文件更详细些。
?
?
400df000-4048c000 r--s 00000000 1f:05 286 /data/dalvik-cache/system@framework@core.jar@classes.dexSize: 3764 kBRss: 1804 kBPss: 1804 kBShared_Clean: 0 kBShared_Dirty: 0 kBPrivate_Clean: 1804 kBPrivate_Dirty: 0 kBReferenced: 1804 kBAnonymous: 0 kBSwap: 0 kBKernelPageSize: 4 kBMMUPageSize: 4 kB
?
?
以上述输出结果为例:400df000-4048c000 r--s 00000000 1f:05 286 /data/dalvik-cache/system@framework@core.jar@classes.dex
其中Dirty页面如果没有交换机制的情况下,应该是不能回收的。
精确分析内存占用可以用Private内存信息来衡量。
?
详细解释见 http://www.kernel.org/doc/Documentation/filesystems/proc.txt
The first of these lines shows the same information as is displayed for themapping in /proc/PID/maps. The remaining lines show the size of the mapping(size), the amount of the mapping that is currently resident in RAM (RSS), theprocess' proportional share of this mapping (PSS), the number of clean anddirty private pages in the mapping. Note that even a page which is part of aMAP_SHARED mapping, but has only a single pte mapped, i.e. is currently usedby only one process, is accounted as private and not as shared. "Referenced"indicates the amount of memory currently marked as referenced or accessed."Anonymous" shows the amount of memory that does not belong to any file. Evena mapping associated with a file may contain anonymous pages: when MAP_PRIVATEand a page is modified, the file page is replaced by a private anonymous copy."Swap" shows how much would-be-anonymous memory is also used, but out onswap.