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 same 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
?
WSS is the number of pages a process needs in memory to keep "working". RSS is the number of pages of a process that actually reside in main memory. So RSS >= WSS. Meaning that RSS may include some pages that the process doesn't really need right now.
RSS is Resident Set Size (physically resident memory - this is currently occupying space in the machine's physical memory), and VSZ is Virtual Memory Size (address space allocated - this has addresses allocated in the process's memory map, but there isn't necessarily any actual memory behind it all right now).
In computing, resident set size (RSS) is the portion of memory occupied by a process that is held in main memory (RAM). The rest of the occupied memory exists in the swap space or file system, either because some parts of the occupied memory were paged out, or because some parts of the executable were never loaded.
PS service RSS stands for Resident Set Size and shows how much RAM is utilized at the time the command is output. It also should be noted that it shows the entire stack of physically allocated memory.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With