“免费”输出从14.04到16.04的变化是什么意思?
我注意到free
命令报告在Trusty和Xenial之间发生了变化。 以下是我的一台Trusty计算机上显示的“free -m”:
$ free -m total used free shared buffers cached Mem: 7916 7645 271 99 455 1764 -/+ buffers/cache: 5426 2490 Swap: 24999 805 24194
这是(一个不同的)Xenial系统的等价物:
$ free -m total used free shared buff/cache available Mem: 3553 1192 857 16 1504 2277 Swap: 3689 0 3689
我主要用来看的+/-缓冲区/缓存行已经消失了。 我该如何解释新数字?
- Mem使用/ free是否包含缓冲区和缓存?
- 哪个数字相当于早期版本的“+/- buffers / cache”行中的已用数字和空闲数字?
请考虑我从Ubuntu 12.04
的free
命令获得的示例输出:
total used free shared buffers cached Mem: 8074640 6187480 1887160 377056 365128 2113156 -/+ buffers/cache: 3709196 4365444 Swap: 15998972 82120 15916852
Mem used
(kb_main_used)字段值现在计算如下:
used = total - free - cached - buffers
以前,它曾经是:
used = total - free
此更改在以下提交中引入https://gitlab.com/procps-ng/procps/commit/6cb75efef85f735b72e6c96f197f358f511f8ed9
中间值:
buffers_plus_cached = buffers (kb_main_buffers) + cached (kb_main_cached) = 365128 + 2113156 = 2478284
+/-缓冲区/缓存值的计算方式如下:
buffers = kb_main_used - buffers_plus_cached = 6187480 - 2478284 = 3709196 / cache = kb_main_free + buffers_plus_cached = 1887160 + 2478284 = 4365444
新的buff /缓存值计算如下:
buff/cache = kb_main_buffers+kb_main_cached = 365128 + 2113156 = 2478284
这与之前版本中使用的buffers_plus_cached
相同,区别在于之前它在内部使用,现在直接显示,并且已经删除了进一步计算的行-/+ buffers/cache
有关详细信息,请查看这些提交,其中介绍了这些更改: https : //gitlab.com/procps-ng/procps/commit/f47001c9e91a1e9b12db4497051a212cf49a87b1 https://gitlab.com/procps-ng/procps/commit/c9908b59712d1afd6b9bf7971ba1d8900ae5adb8
对于新的available
字段,对于早于2.6.27的Linux内核,其值与free
值相同,但对于更高版本的内核,它有点不同:
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)
礼貌: http : //manpages.ubuntu.com/manpages/xenial/en/man1/free.1.html
那么,你问题的具体答案是:
- 新版本的
free
包括在Mem used/free
值的计算中的缓冲区/缓存。 - 之前版本的
free
版中曾经存在的+/- buffers/cache
值现在可用:- – / + buffers / cache
used
= CurrentMem used
column(其计算如上所述) - – / + buffers / cache
free
可用作当前新列中更准确的值
- – / + buffers / cache
注意: kb_*
变量名是源代码中使用的内部名称。