正确理解 output of linux command free

linux command free is used to show the RAM usage of the system. Below is an example output of the command: 

$ free -m

                     total       used       free     shared    buffers     cached

Mem:          2000       1921         78          0          6         34

-/+ buffers/cache:       1881        119

Swap:            0          0          0

The "-m" switch outputs in megabyte. So the system:

  1. has total RAM of 2G.
  2. Used 1921M, but in this Used Mem, it includes 6M as buffers and 34M for cached data.
  3. Absolutely free (not used by anything) memory is 78M.
  4. If necessary, the system can use the buffered and cached memory for other processes. Therefore, the actual used memory is "used" - "buffers" - "cached", ie. 1921 - 6 - 34 = 1881M. This is lised on the 2nd line of the output:          "-/+ buffers/cache  1881  119".
  5. Note the "-/+ buffers/cache  1881  119" has a "-/+" at the beginning. I think "-" means what we talked about in point 4. While "+" means that the actual free memory is "free" + "buffers" + "cached" = 78 + 6 + 34 (roughly 119M). Since the system can use that 119M for other processes (at most 119M can be allocated as free memory).

相关推荐