# CentOS 6及以前

$free total used free shared buffers cached Mem: 4040360 4012200 28160 0 176628 3571348 -/+ buffers/cache: 264224 3776136 Swap: 4200956 12184 4188772$

• A. 程序使用的；
• B. 未被分配的；
• C. Buffers (buffer cache)
• D. Cached (page cache)

• 第一行(Mem)：Buffers和Cached被算作used。也就是说，它的free是指 B (未被分配的)；它的used是指 A ＋ C ＋ D；
• 第二行(-/+ buffers/cache)：Buffers和Cached被算作free。也就是说，它的used是指 A (程序使用的)；它的free是指 B + C + D；行名称“-/+ buffers/cache”的含义就是“把Buffers和Cached从used减下来，加到free里”。

• A＝264224
• B＝28160
• C＝176628
• D＝3571348

• total＝A ＋ B ＋ C ＋ D
• 第一行used ＝ A ＋ C ＋ D
• 第二行free  ＝ B ＋ C ＋ D

# CentOS 7

free命令的out：
              total        used        free      shared  buff/cache   available
Mem:        1012952      252740      158732       11108      601480      543584
Swap:       1048572        5380     1043192

• MemAvailable: An estimate of how much memory is available for starting new applications, without swapping.

/proc/meminfo: provide estimated available memory

Many load balancing and workload placing programs check /proc/meminfo to estimate how much free memory
is available. They generally do this by adding up "free" and "cached", which was fine ten years ago,
but is pretty much guaranteed to be wrong today.
It is wrong because Cached includes memory that is not freeable as page cache, for example shared memory
segments, tmpfs, and ramfs, and it do esnot include reclaimable slab memory, which can take up a large
fraction of system memory on mostly idle systems with lots of files.
Currently, the amount of memory that is available for a new workload,without pushing the system into swap,
can be estimated from MemFree, Active(file), Inactive(file), and SReclaimable, as well as the "low"watermarks
from /proc/zoneinfo.
However, this may change in the future, and user space really should not be expected to know kernel internals
to come up with an estimate for the amount of free memory.
It is more convenient to provide such an estimate in /proc/meminfo. If things change in the future, we only
have to change it in one place.