-/+ buffers/cache 在 free 的输出中是什么意思?

Nav*_*rya 7 linux memory

我知道这是一个蹩脚的问题,但我想了解为什么 CentOS 在某些进程停止时会消耗我的物理内存。假设我打开了一个 10GB 的文件,当我完成该过程并关闭文件时,它消耗了 10GB 的内存和缓冲区,然后 CentOS 仍然保留了我的 10GB 内存。

当我运行free命令时,它给了我以下详细信息:

11.4 GB are used
in buffers: 6336
in cached: 49168

-/+ buffers/cache: 11.4GB used
Run Code Online (Sandbox Code Playgroud)

当我尝试使用以下解决方案释放内存时:

如何清空 Linux 系统上的缓冲区和缓存?

如何在 Linux 中清除内存缓存

设置 /proc/sys/vm/drop_caches 以清除缓存

-/+ 缓冲区/缓存:仍保留 11.4 GB。

blu*_*ggy 8

首先,除非您有特定要求,否则您不需要释放任何缓冲区或自己缓存。Linux 保存缓存以提高内存访问的性能。缓冲区只是临时位置,缓存和缓冲区都会根据 Linux 正在执行的任务不断变化。

有一个链接很好地描述了这些字段http://www.linuxnix.com/2013/05/find-ram-size-in-linuxunix.html

更新新链接:https : //www.linuxnix.com/find-ram-size-in-linuxunix/

如果将来链接不起作用,这里还有更多的解释。下面是输出free -m

             total       used       free     shared    buffers     cached
Mem:          7753       2765       4987          0         24        570
-/+ buffers/cache:       2171       5582
Swap:         8191          0       8191
Run Code Online (Sandbox Code Playgroud)

-/+ 在第二行:

Total used RAM is (2765) - (24 + 570) = 2171 [ - in the second line]
Total Free RAM is (7753 - 2765) + (24 + 570 ) = 5582 [ + in the second line ]
Run Code Online (Sandbox Code Playgroud)