开发者

Are the pmap's RSS and htop's RES the same?

I run the following simple program

#include <stdio.h>
#include <stdlib.h>    
int
main() {
  malloc(1024*1024*32);
  getchar();
  return 0;
}

htop gives this

VIRT   RES   SHR
36684  312   240

pmap -x gives this

Address           Kbytes     RSS   Dirty Mode   Mapping
0000000000400000       0       4       0 r-x--  a.out
0000000000600000       0       4       4 r----  a.out
0000000000601000       0       4       4 rw---  a.out
00007f063d3b7000       0       4       4 rw---    [ anon ]
00007f063f3b8000       0     228       0 r-x--  libc-2.12.1.so
00007f063f532000       0       0       0 -----  libc-2.12.1.so
00007f063f731000       0      16      16 r----  libc-2.12.1.so
00007f063f735000       0       4       4 rw---  libc-2.12.1.so
00007f063f736000       0      12      12 rw---    [ anon ]
00007f063f73b000       0     108       0 r-x--  ld-2.12.1.so
00007f063f93d000       0      12      12 rw---    [ anon ]
00007f063f958000       0       8       8 rw---    [ anon ]
00007f063f95b000       0       4       4 r----  ld-2.12.1.so
00007f063f95c000       0       4       4 rw---  ld-2.12.1.so
00007f063f95d000       0       4       4 rw---    [ anon ]
00007fff4b298000       0      12      12 rw---    [ stack ]
00007fff4b2d7000       0       4       0 r-x--    [ anon ]
ffffffffff600000       0       0       0 r-x--    [ anon ]
----------------  ------  ------  ------
total kB           36684     432      88

htop and pmap show the 开发者_如何学Gosame virtual size(36684), but they shows different things for physical memory (htop's RES = 321 and pmap's RSS = 432).

Maybe I confuse something but is there any difference between htop's RES and pmap's RSS?


So, from the man page for top we see that:

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

and for pmap:

RSS: resident set size in kilobytes

So they seem to be the same thing. But actually, if you also check with ps you will see that htop will show the same RES as ps's RSS. The thing is that ps mentions in the man that they show a measurement a little bit different:

The SIZE and RSS fields don’t count some parts of a process including the page tables, kernel stack, struct thread_info, and struct task_struct. This is usually at least 20 KiB of memory that is always resident. SIZE is the virtual size of the process (code+data+stack).

So that would be the difference between ps and pmap and it's actually the same for htop and pmap.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜