ps

This is the basic command to see process list with memory usage. Here the memory related columns is %MEM
, VSZ
and RSS
.
VSZ
is total amount of memory this process is allowed to use which was requested with various functions such asmalloc
,mmap
,shmctl
, etc. It does not represent the physically allocated amount.RSS
is total amount of memory this process is currently occupying in physical memory. So, checking the memory usage is usually done with this. However, there is one caution here. If there is a shared memory, accumulating each processesRSS
may become bigger than the total physical memory size.
pmap

pmap shows the memory allocation layout in a process. You can check what shared object (.so) files are loaded, how much is allocated in heap, how much is used for stack, etc.
/proc/<pid>/maps

This proc file provides similar output from pmap
. You can get similar output using pmap -x
or pmap -XX
.
/proc/<pid>/smaps

This is similar to /proc/<pid>/maps
, but also provide detailed information for each memory chunk. It is quite useful, especially to find out how much amount is actually allocated in physical memory.
In the above, Rss:
is showing how much is allocated in the physical memory. However, it has one issue when you are trying to get total Rss:
by traversing each processes as each processes may have some shared memory blocks. For this matter, Pss:
has been introduced. This is aware how many processes are sharing this shared memory block and divide it by the total number.

In the above, the Rss:
is 160 kB
, but Pss:
has 1 kB
. It means there are 160 processes sharing this /usr/lib64/libc.so.6
shared object. You can find some further details about this in this link. https://lwn.net/Articles/230975/
Leave a Reply