总内存和可用内存有什么区别


11

我有一个安装了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

在total列中,表示总计为11GB(是正确的),在最后一列中,则表示6.6GB已使用的是4.6G。

如果使用的内存为4.6 GB,则剩余容量应为6.4 GB(11-4.6 = 6.4)。以上输出的正确解释是什么?总内存与可用内存和可用内存之间有何区别?如果某些新应用程序需要1 GB以上的内存,我的内存不足吗?


所以你的问题是为什么它是6.6而不是6.4?
αԋɱҽԃαмєяιcαη

1
这个问题可以追溯到几十年前..您如何指代当前用作高速缓存但“可用或空闲”的内存。即。它包含磁盘中的数据,因此在需要时为“缓存”;但适用于应用程序malloc()。您担心的差异有助于我们了解此“将价值放置在何处”使用了多少内存,并且自80年代以来每隔几年就进行辩论。它不会像往常一样保持不变(annoying.figure很有用!而且保持不变并不意味着我们必须修改使用它的几十年的旧脚本)
guiverc

Answers:


14

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)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.