Understanding memory usage/health in linux server

Understanding memory usange/health in linux server

Command: watch -n 5 free -m

Every 5.0s: free -m

TotalUsedFreeSharedBuffersCached
Mem395126901261111692298
-/+ buffers/cache2223729
Swap000

total used free shared buffers cached
Mem: 3951 2690 1261 11 169 2298
-/+ buffers/cache: 222 3729
Swap: 0 0 0

In the output the first line means:

Total(column): Your total (physical) RAM.
used(column): memory in use by the OS.
free(column): memory not in use.

total = used + free

shared, buffers, cached(columns): These columns shows memory usage for particular purposes, these values are included in the value for used.

The second line gives first line values adjusted. It gives the original value for used minus the sum buffers+cached and the original value for free plus the sum buffers+cached, hence its title. These new values are often more meaningful than those of first line.

The last line (Swap:) gives information about swap space usage (i.e. memory contents that have been temporarily moved to disk).

To actually understand what the numbers mean, you need a bit of background about the virtual memory (VM) subsystem in Linux. Just a short version: Linux (like most modern OS) will always try to use free RAM for caching stuff, so Mem: free will almost always be very low. Therefore the line -/+ buffers/cache: is shown, because it shows how much memory is free when ignoring caches; caches will be freed automatically if memory gets scarce, so they do not really matter.

IMPORTANT: A Linux system is really low on memory if the free value in -/+ buffers/cache: line gets low.

So in our case it seems from the first line that 2690mb out of 3951mb is used, which may be a critical sign. But Actually most of the memory is used in caching which is not a problem at all. So look at the second row where it shows (-buffers/cache) only 222mb is consumed. So the health of the memory is perfectly ok.

Comments