正确理解 output of linux command free

本文解析了Linux中free命令的使用方法及其输出含义,通过实例详细解释了如何查看系统的内存使用情况,包括总内存、已用内存、空闲内存、缓存和交换分区等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

linux command free is used to show the RAM usage of the system. Below is an example output of the command: 

 

$ free -m

                     total       used       free     shared    buffers     cached

Mem:          2000       1921         78          0          6         34

-/+ buffers/cache:       1881        119

Swap:            0          0          0

 

The "-m" switch outputs in megabyte. So the system:

 

  1. has total RAM of 2G.
  2. Used 1921M, but in this Used Mem, it includes 6M as buffers and 34M for cached data.
  3. Absolutely free (not used by anything) memory is 78M.
  4. If necessary, the system can use the buffered and cached memory for other processes. Therefore, the actual used memory is "used" - "buffers" - "cached", ie. 1921 - 6 - 34 = 1881M. This is lised on the 2nd line of the output:          "-/+ buffers/cache  1881  119".
  5. Note the "-/+ buffers/cache  1881  119" has a "-/+" at the beginning. I think "-" means what we talked about in point 4. While "+" means that the actual free memory is "free" + "buffers" + "cached" = 78 + 6 + 34 (roughly 119M). Since the system can use that 119M for other processes (at most 119M can be allocated as free memory).
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值