free命令

来源:互联网 发布:2017淘宝蓝海类目 编辑:程序博客网 时间:2024/05/07 08:38

某日,使用top查看linux机器内存使用情况

Mem:   8191876k total,  8070284k used,   121592k free,    80196k buffersSwap:        0k total,        0k used,        0k free,  6041496k cached

第一眼看了free只有121592k ,共8G的内存,以为快用完了,咨询得知Mem包含了:
应用程序内存 + buffers+ cache,需要用free命令查看。

free -M

            total       used       free     shared    buffers     cachedMem:          7999       7865        134          0         82       5878-/+ buffers/cache:       1904       6095

查了查free的用法,得知

DESCRIPTION
       free  displays the total amount of free and used physical and swap memory in the sys-
       tem, as well as the buffers used by the kernel.  The shared memory column  should  be
       ignored; it is obsolete.


计算方法:
物理已用内存 = 实际已用内存 -buffers- cache = 7865M -82M - 5878M

物理空闲内存 = 总物理内存 - 实际已用内存 + bufffers + cache

应用程序可用空闲内存 = 总物理内存 - 实际已用内存

应用程序已用内存 = 实际已用内存 - buffers-cache

  • 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.

buffer是用于存放要输出到disk(块设备)的数据的-------缓冲

cache是存放从disk上读出的数据-------缓存

这二者是为了提高IO性能的,并由OS管理。Linux和其他成熟的操作系统(例如windows),为了提高IO read的性能,总是要多cache一些数据


0 0
原创粉丝点击