问题
Just looking for some quick help regarding free -m
output on Linux. Here's an example on one of my servers:
$free -m
total used free shared buffers cached
Mem: 14881 14813 68 0 262 883
-/+ buffers/cache: 13667 1213
Swap: 4095 240 3855
I understand the kernel can and will use available memory for disk caching to speed up the system.
Normally, I look at the second value in the "free" column, in the above case it's 1213. It's normally a lot higher than this.
I guess I am looking to understand what the two outputs next to '-/+ buffers/cache' mean. From what I can see, the system truly is low on memory (only 1213MB available for applications to use) and the OS actually needs 13GB for caching?
回答1:
This has been answered in serverfault. Here is the relevant excerpt:
total
= used
+ free
shared
/buffers
/cached
: This shows memory usage for specific purposes, these values are included in the value forused
.
The second line gives first line values adjusted. It gives the original value for used
minus the sum buffers+cached
and the original value for free
plus the sum buffers+cached
, hence its title. These new values are often more meaningful than those of first line.
[End of excerpt]
Focusing on your situation,
- 14813 (used memory) - 262 (buffered) - 883 (cached) = 13668 (used by applications).
In the event an application needs more memory, it can be taken either from free memory or from cached/buffered, so:
- 262 (buffered) + 883 (cached) + 68 (not used at all) = 1213 (available to applications).
The system does not really need 262+883=1145 (not 13GB) for cache and buffers, but since it's there, it takes it (but gives it back if applications need more). Take a look at the Linux ate my RAM! page.
You can also use top
(I personally prefer htop
) to see the memory status and which applications are taking most RAM.
As an example, here is a screenshot of htop running in my RaspberryPi and the free -h
execution:

raspberry ~ # free -h
total used free shared buffers cached
Mem: 183M 178M 5,3M 0B 63M 42M
-/+ buffers/cache: 72M 111M
Swap: 0B 0B 0B
来源:https://stackoverflow.com/questions/24643807/understanding-buffers-cache-in-linux-free-m