我有一个安装了 Centos 7 的桌面系统。它有 4 核和 12 GB 内存。为了查找内存信息,我使用free -h
命令。我有一个困惑。
[user@xyz-hi ~]$ free -h
total used free shared buff/cache available
Mem: 11G 4.6G 231M 94M 6.8G 6.6G
Swap: 3.9G 104M 3.8G
在总列中,它说总计为 11GB(这是正确的),在可用的最后一列中,它说 6.6GB,已使用的是 4.6G。
如果已用内存为 4.6 GB,则剩余内存应为 6.4 GB (11-4.6=6.4)。上述输出的正确解释是什么 总内存、可用内存和空闲内存之间有什么区别?如果我需要 1 GB 以上的内存用于某些新应用程序,我是否会出现内存不足的情况?
答案1
man free
命令解决我的问题。
DESCRIPTION
free displays the total amount of free and used physical and swap mem‐
ory in the system, as well as the buffers and caches used by the ker‐
nel. The information is gathered by parsing /proc/meminfo. The dis‐
played 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, available
on kernels 2.6.32, displayed as zero if not available)
buffers
Memory used by kernel buffers (Buffers in /proc/meminfo)
cache Memory used by the page cache and slabs (Cached and Slab 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, avail‐
able on kernels 3.14, emulated on kernels 2.6.27+, otherwise the
same as free)