$ pmap -x 10400
10400: ./a.out
Address Kbytes RSS Dirty Mode Mapping
0000000000400000 0 0 0 r-x-- a.out
0000000000600000 0 4 4 r---- a.out
0000000000601000 0 4 4 rw--- a.out
00007f957085f000 0 4 0 r-x-- libc-2.15.so
00007f9570a12000 0 0 0 ----- libc-2.15.so
00007f9570c11000 0 16 16 r---- libc-2.15.so
00007f9570c15000 0 8 8 rw--- libc-2.15.so
00007f9570c17000 0 8 8 rw--- [ anon ]
00007f9570c1c000 0 0 0 r-x-- ld-2.15.so
00007f9570e1f000 0 12 12 rw--- [ anon ]
00007f9570e3c000 0 8 8 rw--- [ anon ]
00007f9570e3e000 0 4 4 r---- ld-2.15.so
00007f9570e3f000 0 8 8 rw--- ld-2.15.so
00007fff18a6d000 0 12 12 rw--- [ stack ]
00007fff18bff000 0 4 0 r-x-- [ anon ]
ffffffffff600000 0 0 0 r-x-- [ anon ]
---------------- ------ ------ ------
total kB 4148 92 84
RSS 是 92
$ ps -o rss,sz,vsz 10400
RSS SZ VSZ
80 1037 4148
Run Code Online (Sandbox Code Playgroud)
RSS 是 80
为什么以及发生了什么?
从 ps 的手册页:
\n\n The SIZE and RSS fields don\xe2\x80\x99t count some parts of a process including\n the page tables, kernel stack, struct thread_info, and struct\n task_struct. This is usually at least 20 KiB of memory that is always\n resident. SIZE is the virtual size of the process (code+data+stack).\nRun Code Online (Sandbox Code Playgroud)\n