在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.

[Linux] Linux smaps接口文件结构的更多相关文章

  1. linux网络socket 接口转

    linux网络socket 接口 1.socket函数:一个进程必须做的第一件事就是调用socket函数获得一个文件描述符. ------------------------------------- ...

  2. Linux 文件操作接口

    目录 Linux 文件操作接口 C语言文件操作接口 C语言文件描述 fopen() r模式打开文件 w模式打开文件 a模式打开文件 其他模式类似 fclose() fwrite() fread() 系 ...

  3. [Linux]Linux下安装和配置solr/tomcat/IK分词器 详细实例二.

    为了更好的排版, 所以将IK分词器的安装重启了一篇博文,  大家可以接上solr的安装一同查看.[Linux]Linux下安装和配置solr/tomcat/IK分词器 详细实例一: http://ww ...

  4. [Linux]Linux下redis的安装及配置.

    在上一篇[Linux] linux下安装配置 zookeeper/redis/solr/tomcat/IK分词器 详细实例. 我们已经将redis所需tar包拷贝到了linux下的root 根目录下, ...

  5. linux与linux,linux与windows之间用SSH传输文件

    linux与linux,linux与windows之间用SSH传输文件linux与linux之间传送文件:scp file username@hostIP:文件地址    例: scp abc.txt ...

  6. WSL优化 (Windows Subsystem for Linux) Linux子系统优化配置

    目录 wsl优化 (Windows Subsystem for Linux) Linux子系统优化 1. 永久修改wsl终端字体 2. 修改Linux终端配色 3. 添加WSL到右键菜单 wsl优化 ...

  7. [Linux]Linux下开启snmp支持IPV4和IPV6

    SNMP简介 简单网络管理协议(SNMP),由一组网络管理的标准组成,包含一个应用层协议(application layer protocol).数据库模型(database schema)和一组资源 ...

  8. linux linux系统常用设置

    linux  linux系统常用设置 一.设置开机时开启数字键 修改rc.local文件 命令:vi  /etc/rc.local rc.local文件中增加如下代码: INITTY=/dev/tty ...

  9. linux linux系统的安装及使用

    linux  linux系统的安装及使用 一.linux系统中安装vm-tools工具: 步骤: 1.在vmware workstation软件中:虚拟机-安装vmware-tools-状态栏会提示- ...

随机推荐

  1. PHP-5.3.27源码安装及nginx-fastcgi配置

    源码安装php cat /etc/redhat-release uname -rm wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.c ...

  2. udp调用connect有什么作用(转)

    原文链接如下: http://blog.csdn.net/wannew/article/details/18218619 整理一下.1:UDP中可以使用connect系统调用 2:UDP中connec ...

  3. [ 总结 ] Linux系统启动流程

    Linux系统启动过程分析: 按下电源 --> BIOS自检 --> 系统引导(lilo/grub) --> 启动内核 --> 初始化系统 --> 用户登录 1. BIO ...

  4. 虚拟存储管理中几种缺页中断算法(最佳置换法OPT)

    缺页中断就是要访问的页不在主存,需要操作系统将其调入主存后再进行访问. 在进行内存访问时,若所访问的页已在主存,则称此次访问成功: 若所访问的页不在主存,则称此次访问失败,并产生缺页中断. 最佳置换法 ...

  5. Leetcode 之Flatten Binary Tree to Linked List(50)

    将左子树接到右子树之前,递归解决 void flatten(TreeNode *root) { if (root == nullptr)return; flatten(root->left); ...

  6. hive学习(二) hive操作

    hive   ddl 操作官方手册https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL hive  dml 操作官方手 ...

  7. C语言实现二叉排序树

    程序以'#'结尾的二叉排序树. /*(双重指针 BSTree *T)问:数据结构中 二叉树建立结点为什么用 双重指针?详细解释下双重指针 答:指针的指针.因为树的结点要用指针描述.如果只用指针,作形参 ...

  8. git------删除Repository

    需求:删除仓库 Lucky-Repository,实现步骤如下截图所示 如上完成删除操作

  9. Python软件源PyPI中国镜像 2016

    作为 easy_install 的升级版,pip 为 Pyhton 的包管理提供了极大的方便.一行命令即可完成所需模块的安装: pip install pandas 可是官方镜像的访问速度相当慢,几乎 ...

  10. AC日记——【模板】Link Cut Tree 洛谷 P3690

    [模板]Link Cut Tree 思路: LCT模板: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 30 ...