How to calculate the resident (RSS) part of each anonymous segment (heap) of a given process

https://access.redhat.com/solutions/113103

 SOLUTION 已验证 - 已更新 2013年二月24日10:22 - 

English 

环境

  • Red Hat Enterprise Linux

问题

How can I calculate the resident (RSS) part of each anonymous segment (heap) of a given process?

决议

To get this information it is possible to use the extended mode of pmap. Launching pmap -x <pid> the following output is obtained:

Raw

$ pmap -x 2876
2876:   bash
Address           Kbytes     RSS   Dirty Mode   Mapping
0000000000400000     872     572       0 r-x--  bash
00000000006d9000       4       4       4 r----  bash
00000000006da000      36      36      36 rw---  bash
00000000006e3000      24      24      24 rw---    [ anon ]
00000000008e2000      36       8       0 rw---  bash
000000000134a000    4200    4116    4116 rw---    [ anon ]
0000003c66e00000     136     120       0 r-x--  ld-2.14.90.so
0000003c67021000       4       4       4 r----  ld-2.14.90.so
0000003c67022000       4       4       4 rw---  ld-2.14.90.so
0000003c67023000       4       4       4 rw---    [ anon ]
0000003c67200000    1716     680       0 r-x--  libc-2.14.90.so
0000003c673ad000    2048       0       0 -----  libc-2.14.90.so
0000003c675ad000      16      16       4 r----  libc-2.14.90.so
0000003c675b1000       8       8       8 rw---  libc-2.14.90.so
0000003c675b3000      20      20      20 rw---    [ anon ]
0000003c67600000       8       8       0 r-x--  libdl-2.14.90.so
0000003c67602000    2048       0       0 -----  libdl-2.14.90.so
0000003c67802000       4       4       4 r----  libdl-2.14.90.so
0000003c67803000       4       4       4 rw---  libdl-2.14.90.so
0000003c68200000      84      16       0 r-x--  libgcc_s-4.6.2-20111027.so.1
0000003c68215000    2044       0       0 -----  libgcc_s-4.6.2-20111027.so.1
0000003c68414000       4       4       4 rw---  libgcc_s-4.6.2-20111027.so.1
0000003c75e00000     140      80       0 r-x--  libtinfo.so.5.9
0000003c75e23000    2044       0       0 -----  libtinfo.so.5.9
0000003c76022000      16      12       4 r----  libtinfo.so.5.9
0000003c76026000       4       4       4 rw---  libtinfo.so.5.9
00007f84ee297000      48      20       0 r-x--  libnss_files-2.14.90.so
00007f84ee2a3000    2044       0       0 -----  libnss_files-2.14.90.so
00007f84ee4a2000       4       4       4 r----  libnss_files-2.14.90.so
00007f84ee4a3000       4       4       4 rw---  libnss_files-2.14.90.so
00007f84ee4a4000  102540      60       0 r----  locale-archive
00007f84f48c7000      16      16      16 rw---    [ anon ]
00007f84f48db000       8       8       8 rw---    [ anon ]
00007f84f48dd000      28      24       0 r--s-  gconv-modules.cache
00007f84f48e4000       4       4       4 rw---    [ anon ]
00007fff80d11000     132      52      52 rw---    [ stack ]
00007fff80d80000       4       4       0 r-x--    [ anon ]
ffffffffff600000       4       0       0 r-x--    [ anon ]
----------------  ------  ------  ------
total kB          120364    5944    4332

By summing all the values from the 3rd columns (RSS) of the lines that have [ anon ] in their mapping column the desired value is obtained.
The following script accomplishes this calculation:

Raw

$ pmap -x $$ | awk '/\[ anon \]/ {total += $3} END {print total}'
4196

NOTE: pmap's output is given in kiloBytes (kB)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值