ps
( process based ) command helps in you in identifying the Memory
Used by a program.The Virtual Size , Resident Set Size are two
important factors of a Process which tells you about the amount of
the Memory Being used by a Program.
When
we use ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME
COMMAND
root002
28453 0.0 1.9 459768 80872 ? Sl May03 7:35 java
root002
29118 0.0 5.1 933384 215696 ? Sl Jul29 4:01 java
root002
32506 0.0 3.4 904408 143832 ? Sl Jul29 1:20 java
VSZ
: Virtual Set Size is the total amount of Memory in swap and also in
RAM. This is in KB's.
RSS
: is Resident Set Size, this is the non-swapped physical memory used
by process in KB's
SHR
: Indicates how much of the VIRT memory is actual share able or
libraries.
If
the VSZ increases over time , then there is a memory leak . We need
to check our code for possible leaks.
If
the Virtual size of your tomcat process is the same after a restart,
or grows to a fixed point and doesn't get any larger, you don't have
a classic memory leak: Your application just likes to use a lot of
memory.
Most
programs running in linux uses shared libraries. Please note that VSZ
and RSS will be showing the memory used by shared libraries along
with the process. Since a shared library used by one process could be
used by another process without duplication, this would result in the
over accounting of memory.
To
get a Clear idea on how much memory is being used we can use the
'pmap' command which gives the memory utilization of all libraries
and process in separate way.
Happy
learning , More To Come :-)