免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 33709 | 回复: 10
打印 上一主题 下一主题

top里RES的详解请教 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-28 12:06 |只看该作者 |倒序浏览
5可用积分
top里有个RES的字段,它所显示的值是进程使用的、未被换出的物理内存大小,RES=CODE+DATA
CODE 可执行代码占用的物理内存大小,单位kb
DATA 可执行代码以外的部分(数据段+栈)占用的物理内存大小,单位kb



比如一个apache的子进程号是8879,我用lsof把mem字段的值加起来来显示它占用的内存值,不过似乎不对,和top里的RES值不一致
命令:
# lsof -c apache |grep 8879 |grep mem|awk 'BEGIN{sum=0}{sum+=$7}END{print sum}'

我想问的是,如何显示一个进程的CODE和DATA的值,RES字段的具体常驻了那些东西。

请高手赐教。

最佳答案

查看完整内容

查看CODE DATA字段topf键设置字段,按r选择CODE,s选择DATA,回车返回统计列表[ 本帖最后由 ynchnluiti 于 2008-11-28 12:24 编辑 ]

论坛徽章:
3
戌狗
日期:2014-09-10 17:07:162015年辞旧岁徽章
日期:2015-03-03 16:54:15wusuopu
日期:2016-06-17 17:43:45
2 [报告]
发表于 2008-11-28 12:06 |只看该作者
原帖由 mageguoshi 于 2008-11-28 12:06 发表
top里有个RES的字段,它所显示的值是进程使用的、未被换出的物理内存大小,RES=CODE+DATA
CODE 可执行代码占用的物理内存大小,单位kb
DATA 可执行代码以外的部分(数据段+栈)占用的物理内存大小,单位kb

...

查看CODE DATA字段
top
f键设置字段,按r选择CODE,s选择DATA,回车返回统计列表

       q: RES  --  Resident size (kb)
          The non-swapped physical memory a task has used.

          RES = CODE + DATA.

       r: CODE  --  Code size (kb)
          The amount of physical memory devoted to executable code, also known as the 'text resident set' size or TRS.

       s: DATA  --  Data+Stack size (kb)
          The amount of physical memory devoted to other than executable code, also known as the 'data resident set' size or DRS.

[ 本帖最后由 ynchnluiti 于 2008-11-28 12:24 编辑 ]

评分

参与人数 1可用积分 +6 收起 理由
luo118 + 6 我很赞同

查看全部评分

论坛徽章:
0
3 [报告]
发表于 2008-11-28 12:27 |只看该作者
good

论坛徽章:
0
4 [报告]
发表于 2008-11-28 12:56 |只看该作者

回复 #1 mageguoshi 的帖子

top如果用的熟练是可以发现一些系统基本的问题或者瓶颈所在的

论坛徽章:
0
5 [报告]
发表于 2008-11-28 13:00 |只看该作者
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  CODE DATA COMMAND                                                
14506 apache    20   0  211m  41m  28m S    6  0.5   0:05.96  356  12m apache2

不是RES=CODE+DATA么?
这里相加好像不等啊。
41m 怎么会等于 356KB+12m

论坛徽章:
0
6 [报告]
发表于 2008-11-28 13:09 |只看该作者
貌似
RES=CODE+DATA+SHR

论坛徽章:
0
7 [报告]
发表于 2008-11-28 13:12 |只看该作者
继续再问个问题,如何查看系统SHR字段的值由哪几部分组成的呢!!

论坛徽章:
0
8 [报告]
发表于 2008-11-28 13:45 |只看该作者

回复 #7 mageguoshi 的帖子

* T: SHR        = Shared Mem size (kb)

论坛徽章:
0
9 [报告]
发表于 2008-11-28 13:46 |只看该作者
lz  找一下 cu  里有top详解

论坛徽章:
0
10 [报告]
发表于 2008-11-28 13:51 |只看该作者
n: %MEM  --  Memory usage (RES)
          A task's currently used share of available physical memory.

       o: VIRT  --  Virtual Image (kb)
          The total amount of virtual memory used by the task.  It includes all code, data and shared libraries plus pages that
          have been swapped out. (Note: you can define the STATSIZE=1 environment variable and the VIRT will be calculated from
          the /proc/#/state VmSize field.)

          VIRT = SWAP + RES.

       p: SWAP  --  Swapped size (kb)
          The swapped out portion of a task's total virtual memory image.

       q: RES  --  Resident size (kb)
          The non-swapped physical memory a task has used.

          RES = CODE + DATA.

       r: CODE  --  Code size (kb)
          The amount of physical memory devoted to executable code, also known as the 'text resident set' size or TRS.

       s: DATA  --  Data+Stack size (kb)
          The amount of physical memory devoted to other than executable code, also known as the 'data resident  set'  size  or
          DRS.

       t: SHR  --  Shared Mem size (kb)
          The  amount  of  shared memory used by a task.  It simply reflects memory that could be potentially shared with other
          processes.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP