linux free命令解释

近期定位一个内存耗尽的问题,重拾了一下free命令的一些输出,觉得有必要解释一下free命令的一些输出。

  • 在linux下执行free命令
    sioss1:/export/home/SANEX9510_CSS # free
totalusedfreesharedbufferscached
Mem:13213023212762692045033120208368870900528
-/+ buffers/cache:5464270477487528
Swap:33558524269994430858580

下面我们把这张表称为free表,通过下标来指代具体的行列,如free[1][1],就是表的第二行第二列,即132130232。

  • free表第二行解释,这个是从OS的角度去统计的
    free[1][1] = 132130232,表示系统总内存有132130232KB
    free[1][2] = 127626920, 表示系统已使用的内存有127626920KB
    free[1][3] = 4503312,表示系统未使用的内存有4503312KB
    free[1][1] = free[1][2] + free[1][3]
    free[1][5] = 2083688KB,
    free[1][6] = 70900528KB
    buffers和cached的解释如下

A buffer is something that has yet to be “written” to disk.
A cache is something that has been “read” from the disk and stored for later use.

  • free表第三行解释,这个是从应用程序的角度去统计的
    free[2][1] = 54642704KB,这个表示应用程序认为系统被用掉了多少内存
    free[2][1] = free[1][2] – free[1][5] – free[1][6],这个是因为buffers和cached回收是非常快速的,直接可以回收给应用程序使用
    free[2][2] = 77487528KB,表示一个应用程序认为系统还有多少内存;
    free[2][2] = free[1][3] + free[1][5] + free[1][6]

  • free表第四行解释,这个是交换空间的使用,比较简单,就不多做解释
    free[3][1] = free[3][2] + free[3][3]

    原文作者:myang199088
    原文地址: https://www.jianshu.com/p/f807544ead8a
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞