Memory 是pmap';s RSS和htop&x27;是一样的吗?

Memory 是pmap';s RSS和htop&x27;是一样的吗?,memory,pmap,htop,Memory,Pmap,Htop,我运行下面的简单程序 #include <stdio.h> #include <stdlib.h> int main() { malloc(1024*1024*32); getchar(); return 0; } pmap-x给出了 Address Kbytes RSS Dirty Mode Mapping 0000000000400000 0 4 0 r-x-- a.out

我运行下面的简单程序

#include <stdio.h>
#include <stdlib.h>    
int
main() {
  malloc(1024*1024*32);
  getchar();
  return 0;
}
pmap-x
给出了

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
pmap
显示相同的虚拟大小(36684),但它们显示的物理内存不同(
htop
RES
=321和
pmap
RSS
=432)


也许我混淆了什么,但是
htop
RES
pmap
RSS
之间有什么区别吗?

因此,从顶部的手册页我们可以看到:

q:RES——驻留大小(kb)
任务使用的非交换物理内存

对于pmap:

RSS:常驻集大小(以KB为单位)

所以它们看起来是一样的。但实际上,如果你也检查ps,你会发现htop将显示与ps的RSS相同的分辨率。问题是ps在《男人》中提到了一个测量值有点不同:

SIZE和RSS字段不计算流程的某些部分,包括 页面表、内核堆栈、结构线程信息和结构 任务结构。这通常是至少20kib的内存,并且总是 居民。SIZE是进程的虚拟大小(代码+数据+堆栈)

这就是ps和pmap之间的区别,实际上htop和pmap是一样的

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