了解 free -m 内存使用情况

了解 free -m 内存使用情况

我不明白这一点。当free -m显示这个时:

             total       used       free     shared    buffers     cached
Mem:         15334      14025       1308          0        258      10918
-/+ buffers/cache:       2848      12485
Swap:          953          0        953

这是否意味着我的第 1 行有 1.4GB 可用空间,或者第 2 行有 12GB 可用空间?

我有 Linux + Nginx + php-fpm + Mysql + Memcached

编辑:

我知道 1.3GB 是未使用的空闲内存,但如果我们删除缓冲区使用量,我的 vps 上实际上有 12GB 的可用内存。这是否意味着我的 vps 的 16GB 超出了我的需要,而且我把它浪费在一台大机器上,因为它有 12GB 可用空间?或者看看第 1 行,我是否认为缓冲区使用了大量内存,这意味着我的机器仍然受益于大量内存,因为缓冲区使用意味着更快的响应?

答案1

第一行显示考虑(添加)用于缓存数据或缓冲 I/O 的内存部分的内存cache使用情况。buffers

另一方面,第二行显示不考虑(扣除)cache和 的内存使用情况buffers

现在您可能想知道,如果新进程需要的内存比第一行中显示的内存更多,即考虑到cache/buffers该缓存中最旧的数据cache将被清除,以便为最新进程腾出空间。因此,您不必担心缓存/缓冲占用的巨大空间。

对编辑的答复:

更多缓存意味着更快的响应。所以,除非它绝对让你烦恼,否则你对此很擅长。

答案2

我建议免费查看手册页(请参阅下面的摘录):

# man free

NAME
       free - Display amount of free and used memory in the system

SYNOPSIS
       free [options]

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 gath‐
       ered 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)

       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)

       cached Memory used by the page cache  (calculated as Cached - Shmem in /proc/meminfo - the Cached value is actually the sum of page cache and tmpfs memory)

相关内容