Meaning of the buffers/cache line in the output of free
I have no idea on calculating the memory in linux. I think it says that 5088232 is used where as 7198224 is free, meaning it is actually consuming 5GB of RAM?
For anyone needing an even more simple, step-by-step explanation, check thoughtsbyclayg.blogspot.com/2008/09/…, his explanation helped me a lot.
This is flat out incorrect. The buff/cache is definitely NOT part of used. I’m just looking at a box with 1G used and 12G buff/cache. unix.stackexchange.com/questions/521488/…
4 Answers 4
Meaning of the values
- total : Your total (physical) RAM (excluding a small bit that the kernel permanently reserves for itself at startup); that’s why it shows ca. 11.7 GiB , and not 12 GiB, which you probably have.
- used : memory in use by the OS.
- free : memory not in use.
- shared / buffers / cached : This shows memory usage for specific purposes, these values are included in the value for used .
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.
The last line ( Swap: ) gives information about swap space usage (i.e. memory contents that have been temporarily moved to disk).
Background
To actually understand what the numbers mean, you need a bit of background about the virtual memory (VM) subsystem in Linux. Just a short version: Linux (like most modern OS) will always try to use free RAM for caching stuff, so Mem: free will almost always be very low. Therefore the line -/+ buffers/cache: is shown, because it shows how much memory is free when ignoring caches; caches will be freed automatically if memory gets scarce, so they do not really matter.
A Linux system is really low on memory if the free value in -/+ buffers/cache: line gets low.
For more details about the meaning of the numbers, see e.g. the questions:
Changes in procps 3.3.10
Note that the output of free was changed in procps 3.3.10 (released in 2014). The columns reported are now «total», «used», «free», «shared», «buff/cache», «available», and the meanings of some of the values changed, mainly to better account for the Linux kernel’s slab cache.
«buff/cache» is very high, how I can free it? [duplicate]
The output of the top command shows that 29GB of memory is used by «buff/cache». What does it mean and how I can free it? It is near to 90% of memory.
Have you read linuxatemyram.com ? If yes and you still have a problem, please edit to explain what problem you have, and show the output of cat /proc/meminfo . If that’s not the case, please say so, and a short answer might be written, because I can’t find any other question to mark this one as a duplicate of :-).
1 Answer 1
You don’t need to free «buff/cache».
«buff/cache» is memory that Linux uses for disk caching, and that will be freed whenever applications require it. So you don’t have to worry if a large amount is being shown in this field, as it doesn’t count as «used» memory.
Both you and Linux agree that memory taken by applications is «used», while memory that isn’t used for anything is «free».
But how do you count memory that is currently used for something, but can still be made available to applications?
You might count that memory as «free» and/or «available». Linux instead counts it as «used», but also «available». (. ) This «something» is (roughly) what top and free calls «buffers» and «cached». Since your and Linux’s terminology differs, you might think you are low on ram when you’re not.
What do the «buff/cache» and «avail mem» fields in top mean?
Within the output of top, there are two fields, marked «buff/cache» and «avail Mem» in the memory and swap usage lines: What do these two fields mean? I’ve tried Googling them, but the results only bring up generic articles on top, and they don’t explain what these fields signify.
3 Answers 3
top ’s manpage doesn’t describe the fields, but free ’s does:
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)
Basically, “buff/cache” counts memory used for data that’s on disk or should end up there soon, and as a result is potentially usable (the corresponding memory can be made available immediately, if it hasn’t been modified since it was read, or given enough time, if it has); “available” measures the amount of memory which can be allocated and used without causing more swapping (see How can I get the amount of available memory portably across distributions? for a lot more detail on that).