November 22, 2010

Memory Usage in Linux

cat /proc/meminfo

Refer : http://www.redhat.com/advice/tips/meminfo.html
free -m

total used free shared buffers
cached
Mem: 7977 7752 224 0 174
5760
-/+ buffers/cache: 1818 6159
Swap: 7931 0 7931

'free' shows that most of the available memory is used by pagecache (disk cache), to avoid disk access and speed up file access. That memory can be reclaimed anytime if a process needs it.

If there is memory to spare, linux uses it for caching. It retains old programs in memory under the assupption they may be used again. Thus the first time you open ooffice it takes longer than the second. If that memory is needed by a running process, it is released from cache.

Worry if it starts swapping.
top -n 1
or
ps efax -o command,vsize,rss,%mem,size
grep MemTotal /proc/meminfo
grep SwapTotal /proc/meminfo

You can also examine some of your larger executables to see if they were built with the appropriate compiler and linker options. To identify the largest programs, try using a command such as this:
ls -s1 /bin /usr/bin /usr/bin/X11 | sort -n | tail

Memory use by which process Centos / RHEL /Fedora
#ps aux | awk '{if ($5 != 0 ) print $2,$5,$6,$11}' | sort –k2n