Free Command – Understanding Output Format

cachecommand linememory

I use free to get the amount of free space on some of my servers. Its output is something like:

$ free -m
             total       used       free     shared    buffers     cached
Mem:           374        366          8          0         58         98
-/+ buffers/cache:        209        165
Swap:         1906        120       1785

How much free space do I really have?

Best Answer

The first line of the free output lists:

  • total Your total, physical (assuming no virtualization) memory
  • used How much of that is currently used (by anything)
  • free How much of that is completely free (not used at all)
  • shared Memory used (mostly) by tmpfs (for Linux, kernel >= 2.6.32)
  • buffers Memory used by kernel buffers
  • cached Memory used for cache

The last two items, cache and buffers, is memory that is not allocated to specific user processes. It is memory reserved by the kernel to improve performance overall, but is not "application" memory. These areas will grow or shrink depending on kernel policies with respect to caching, memory pressure, application I/O patterns, etc.

Since these two columns are not user-allocated memory, and the zones can shrink (practically to zero) if user allocations require it, they are in a sense "free" - there's RAM there that can be freed up by the kernel if your apps actively need it.

That's what the second line tells you. It removes the buffer and cache memory from the used column (that's what the - means), and adds (+) them to the free column. (Rounding issue will happen.)

(The last line shows the state of your swap space.)

Related Question