html tool

2018年5月14日星期一

free补



# # free
              total        used        free      shared  buff/cache   available
Mem:        1883432      195080      463300        8812     1225052     1447468
Swap:        524284           0      524284
# free -V
free from procps-ng 3.3.10 

man free [3.3.10 ]
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 gathered 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 - 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, available on kernels 3.14, emulated on kernels 2.6.27+, otherwise the same as free)



---------------------------------------------------------------------------


# $ free
             total       used       free     shared    buffers     cached
Mem:       3860448    3692236     168212        156     275960     826952
-/+ buffers/cache:    2589324    1271124
Swap:       524280       4728     519552

# free -V
procps version 3.2.8


http://www.cnblogs.com/coldplayerest/archive/2010/02/20/1669949.html
free的输出一共有四行,第四行为交换区的信息,分别是交换的总量(total),使用量(used)和有多少空闲的交换区(free),这个比较清楚,不说太多。
  free输出地第二行和第三行是比较让人迷惑的。这两行都是说明内存使用情况的。第一列是总量(total),第二列是使用量(used),第三列是可用量(free)。
  第一行的输出时从操作系统(OS)来看的。也就是说,从OS的角度来看,计算机上一共有:
  • 24677460KB(缺省时free的单位为KB)物理内存,即FO[2][1];
  • 在这些物理内存中有23276064KB(即FO[2][2])被使用了;
  • 还用1401396KB(即FO[2][3])是可用的;
这里得到第一个等式:
  • FO[2][1] = FO[2][2] + FO[2][3]

1 条评论:

  1. free 与 available 的区别
    free 是真正尚未被使用的物理内存数量。
    available 是应用程序认为可用内存数量,available = free + buffer + cache (注:只是大概的计算方法)

    Linux 为了提升读写性能,会消耗一部分内存资源缓存磁盘数据,对于内核来说,buffer 和 cache 其实都属于已经被使用的内存。但当应用程序申请内存时,如果 free 内存不够,内核就会回收 buffer 和 cache 的内存来满足应用程序的请求

    https://blog.csdn.net/gpcsy/article/details/84951675

    回复删除