root@linux:~# free -h total used free shared buff/cache available Mem: 7.8G 172M 7.0G 6.1M 656M 7.4G Swap: 0B 0B 0B
这里的buffer 和cache 是什么意思呢?我们可以通过 man free 查看解释
DESCRIPTION free displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel. The information is gathered by parsing /proc/meminfo. The displayed columns are:
total Total installed memory (MemTotal and SwapTotal in /proc/meminfo)
used Used memory (calculated as total - free - buffers - cache)
free Unused memory (MemFree and SwapFree in /proc/meminfo)
shared Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)
buffers Memory used by kernel buffers (Buffers in /proc/meminfo)
cache Memory used by the page cache and slabs (Cached and SReclaimable in /proc/meminfo)
buff/cache Sum of buffers and cache
available Estimation of how much memory is available for starting new applications, without swapping. Unlike the data provided by the cache or free fields, this field takes into account page cache and also that not all reclaimable memory slabs will be reclaimed due to items being in use (MemAvailable in /proc/meminfo, available on kernels 3.14, emulated on kernels 2.6.27+, otherwise the same as free)
Buffers %lu Relatively temporary storage for raw disk blocks that shouldn't get tremendously large (20MB or so).
Cached %lu In-memory cache for files readfromthe disk (the page cache). Doesn't include SwapCached. SReclaimable %lu (since Linux 2.6.19) Part of Slab, that might be reclaimed, such as caches.
SUnreclaim %lu (since Linux 2.6.19) Part of Slab, that cannot be reclaimed on memory pressure.
root@linux:~# vmstat 1 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0007790168349218878000314912094009900 000779016034921888160000761720010000 000779016034921888160000882220110000 000779016034921888160000831990010000 0007790192350018881600024872150010010 000779019235001888160000761740010000 000779019235001888160000772050010000 0007790192350018881600001252920010000 00077901923500188816000344215198009730 000779019235001888160000641820010000 100779019235001888160000822010110000 000779019235001888160000651530010000 000779019235001888160000581440010000