首页 技术 正文
技术 2022年11月21日
0 收藏 799 点赞 2,499 浏览 1899 个字

在Linux内核 2.6.16中引入了一个系统内存接口特性,这个接口位于/proc/$pid/目录下的smaps文件中 ,一看内容发现是进程内存映像信息,比同一目录下的maps文件更详细些。

400df000-4048c000 r--s 00000000 1f:05 286        /data/dalvik-cache/system@framework@core.jar@classes.dex
Size: 3764 kB
Rss: 1804 kB
Pss: 1804 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 1804 kB
Private_Dirty: 0 kB
Referenced: 1804 kB
Anonymous: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB

以上述输出结果为例:400df000-4048c000 r–s 00000000 1f:05 286 /data/dalvik-cache/system@framework@core.jar@classes.dex

  • 400df000-4048c000 是该虚拟内存段的开始和结束位置
  • r–s内存段的权限,最后一位p代表私有,s代表共享
  • 00000000 该虚拟内存段在对应的映射文件中的偏移量
  • 1f:05 文件的主设备和次设备号
  • 286 被映射到虚拟内存的文件的索引节点号
  • /data/dalvik-cache/system@framework@core.jar@classes.dex 被映射到虚拟内存的文件名称。后面带(deleted)的是内存数据,可以被销毁。
  • size 是进程使用内存空间,并不一定实际分配了内存(VSS)
  • Rss是实际分配的内存(不需要缺页中断就可以使用的)
  • Pss是平摊计算后的使用内存(有些内存会和其他进程共享,例如mmap进来的)
  • Shared_Clean 和其他进程共享的未改写页面
  • Shared_Dirty 和其他进程共享的已改写页面
  • Private_Clean 未改写的私有页面页面
  • Private_Dirty 已改写的私有页面页面
  • Referenced 标记为访问和使用的内存大小
  • Anonymous 不来自于文件的内存大小
  • Swap 存在于交换分区的数据大小(如果物理内存有限,可能存在一部分在主存一部分在交换分区)
  • KernelPageSize 内核页大小
  • MMUPageSize    MMU页大小,基本和Kernel页大小相同

其中Dirty页面如果没有交换机制的情况下,应该是不能回收的。
精确分析内存占用可以用Private内存信息来衡量。

详细解释见 http://www.kernel.org/doc/Documentation/filesystems/proc.txt

The first of these lines shows the same information as is displayed for the
mapping 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), the
process' proportional share of this mapping (PSS), the number of clean and
dirty private pages in the mapping. Note that even a page which is part of a
MAP_SHARED mapping, but has only a single pte mapped, i.e. is currently used
by 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. Even
a mapping associated with a file may contain anonymous pages: when MAP_PRIVATE
and 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 on
swap.
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,031
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,520
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,368
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,148
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,781
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,860