zoukankan      html  css  js  c++  java
  • Linux 常用命令 | free 详解

    free命令可以显示Linux系统中空闲的、已用的物理内存及swap内存,及被内核使用的buffer。在Linux系统监控的工具中,free命令是最经常使用的命令之一。本文介绍free命令的使用方法和数值解释。

    可以看到,自由输出的是一个表格,其中的数值都默认以字节为单位。表格总共有两行六列,这两行分别是物理内存Swap的使用情况,而六列中,每列数据的含义分别为:

    • 第一列,总是总内存大小;

    • 第二列,使用是已使用内存的大小,包含了共享内存;

    • 第三列,自由是未使用内存的大小;

    • 第四列,共享是共享内存的大小;

    • 第五列,浅黄色/高速缓存是缓存和缓冲区的大小;

    • 最后一列,可以是新进程可用内存的大小。

    注意一下,最后一列的可用内存available.available不仅包含未使用内存,还包括了可回收的缓存,所以一般会比未使用内存更大。不过,并不是所有缓存都可以回收,因为有些缓存可能正在使用中。

    这里的缓冲和缓存是什么意思呢?我们可以通过man free查看解释。

    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)
    
           buffers
                  Memory used by kernel buffers (Buffers in /proc/meminfo)
    
           cache  Memory used by the page cache and slabs (Cached and SReclaimable 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)

    可以看到buff和缓存的数据来源都是来自/ proc / meminfo。

    • Buffers是内核缓冲区用到的内存,对应的是/ proc / meminfo中的Buffers值;

    • 缓存是内核页缓存和Slab用到的内存,对应的是/ proc / meminfo中的缓存与SReclaimable之和。

  • 相关阅读:
    关于树状数组区间最值
    Gym 100500B
    RQNOJ Bus
    关于加权的LIS问题
    vs tip1
    小常识
    我的魔方主力
    killer驱动
    从日升的mecha anime看mecha genre的衰退
    关于供给移动端的视频压制
  • 原文地址:https://www.cnblogs.com/wxiaote/p/10976522.html
Copyright © 2011-2022 走看看