Thursday, November 24, 2011

Linux Memory Interpreting - free/vmstat

Interpreting Free

To see how much memory you are currently using, run free -m or free -mt.  It will provide output like:


Free Command: Display Memory Size in MB 

#free -m
             total       used       free     shared    buffers     cached
Mem:           751        626        126          0         36        336
-/+ buffers/cache:        255        497
Swap:          957          0        957

Displays a line containing the totals memory in MB:
#free -m -t

             total       used       free     shared    buffers     cached
Mem:           751        626        126          0         36        336
-/+ buffers/cache:        254        497
Swap:          957          0        957
Total:        1708        626       1083


The key used figure to look at is the buffers/cache row used value.  This is how much space your applications are currently using.  For best performance, this number should be less than your total memory. 

To prevent out of memory errors, it needs to be less than the total memory and swap space.
If you wish to quickly see how much memory is free look at the buffers/cache row free value. This is the total memory - the actual used .


vmstat Command:


The Main thing to see is "b" - their should'nt be more process than configured number of CPU in your machine. Also can see real time buffer and cache memory using 'buff" and "cache" value. 

You can Also see Memory utilization in "Top" Command.

Linux Commands to Monitor Memory Usage:

top  Show top processes
sar -B Show statistics on page swapping.
vmstat  Monitor virtual memory
free  Display amount of free and used memory in the system. (Also: cat /proc/meminfo)
pmap  Display/examine memory map and libraries (so). Usage: pmap pid
cat /proc/sys/vm/freepages Display virtual memory "free pages".
cat /proc/meminfo  Show memory size and usage.

No comments:

Post a Comment