Skip to content
systemcoding.dev
Kernels

Why free Shows So Little Free Memory: Buffers, Cache and Available

The free column on a healthy Linux box is nearly empty because the kernel fills spare RAM with cache. Read the available column instead.

5 min read
Summarize in AI
Flat illustration of user space above the system call boundary, the kernel and the hardware, with the Linux, C and FreeBSD logos.

You log in to a server with 16 GB of RAM, run free -m, and the free column says 614. Four percent. It looks like the machine is about to fall over, and nothing is wrong with it. The kernel treats unused RAM as a waste, so it fills nearly all of it with copies of files it has read from disk, and it hands that memory back the moment a program asks for it. The number you want is available, and this post shows where it comes from.

What free prints

Here is the output of free -m from procps-ng 3.3.17 on a Linux 6.12 desktop that has been up for a few days:

Shell
free -m
Text
               total        used        free      shared  buff/cache   available
Mem:           15884        2150         614         212       13120       12871
Swap:           2047           0        2047

Six numbers, all in mebibytes because of the -m flag. total is the RAM the kernel can use. free is memory that holds nothing at all. buff/cache is memory holding file data, and available is the kernel's own estimate of how much a new program could get without the machine starting to swap. On this version of free, used is total minus free minus buff/cache, so the first three columns add up: 2150 + 614 + 13120 = 15884. Other versions of procps-ng compute used differently, so check the free(1) man page for yours before you do arithmetic on it.

The point of the example: free is 614 MiB and available is 12,871 MiB. The difference is almost entirely the page cache.

Where the numbers come from

free reads /proc/meminfo, a text file the kernel generates on every read. You can see the raw fields yourself:

Shell
grep -E '^(MemTotal|MemFree|MemAvailable|Buffers|Cached|SReclaimable|Shmem):' /proc/meminfo
Text
MemTotal:       16265216 kB
MemFree:          628736 kB
MemAvailable:   13179904 kB
Buffers:          412160 kB
Cached:         12637696 kB
Shmem:            217088 kB
SReclaimable:     385024 kB

The kernel calls the unit kB but means KiB, 1,024 bytes. The free command folds three of these lines into one column: buff/cache is Buffers plus Cached plus SReclaimable. Check it against the numbers above: 412,160 + 12,637,696 + 385,024 is 13,434,880 KiB, which is 13,120 MiB.

What each one holds:

FieldWhat lives thereCan the kernel take it back?
CachedFile data read through the page cache, plus tmpfs and shared memoryClean file pages yes. Shmem pages only by swapping them out
BuffersBlock-device metadata, such as filesystem superblocks and directory blocksMostly yes once clean
SReclaimableKernel slab objects that can be rebuilt, mainly the dentry and inode cachesYes, under pressure
MemFreePages nobody usesAlready free

The Cached line contains Shmem, which is why shared exists as its own column. A tmpfs file or a shm_open region is counted as cache but it is not discardable: there is no file on disk to reload it from. If your buff/cache is huge because someone filled /dev/shm, that memory is not coming back on demand, and available already knows this.

Why the kernel does this

Reading a file from disk costs far more than reading the same bytes from RAM, so the kernel keeps every page it reads. The first cat of a large file goes to the disk. The second is served from memory. Nothing evicts those pages until something else needs the space, and the memory allocator is happy to take them back: clean page-cache pages can be dropped without writing anything.

So a long-running machine drifts toward free near zero by design. It is the steady state, not a leak. The kernel is spending idle RAM on a cache that makes the next read cheaper, with the promise to shrink it when you ask.

What available actually estimates

MemAvailable was added in Linux 3.14 because the old advice, "add free, buffers and cached", was wrong in both directions. The kernel computes it in si_mem_available() in mm/show_mem.c: start from MemFree, subtract the reserve the kernel wants to keep for itself (the sum of the zone low watermarks), add the part of the page cache it expects to be able to drop, and add the reclaimable slab. The page cache term is halved or capped so that a cache that is mostly hot working set is not counted as fully free.

You can reproduce the idea with awk, which is useful as a sanity check on a container where free is missing:

Shell
awk '/^MemTotal:/ {t=$2} /^MemAvailable:/ {a=$2} END {printf "%.1f%% available\n", 100*a/t}' /proc/meminfo
Text
81.0% available

That is 13,179,904 divided by 16,265,216. A healthy box reports a large percentage here even when free looks empty.

Check the cache can really be dropped

If you do not trust the claim, write to the sysctl that makes the kernel drop clean cache. Do this on a test machine, never on a loaded server, because the next reads all go to disk:

Shell
sync
echo 1 | sudo tee /proc/sys/vm/drop_caches
free -m
Text
1
               total        used        free      shared  buff/cache   available
Mem:           15884        2150       12571         212         163       12871
Swap:           2047           0        2047

sync first, because only clean pages can be dropped. Writing 1 drops the page cache, 2 drops dentries and inodes, 3 drops both. Notice that free jumped and available did not move. The estimate was already counting that memory as usable, and that is the reason to read it. The exact figures after the drop depend on what was pinned or dirty at that moment, so yours will differ.

Using drop_caches as a tuning tool is a mistake. It does not make the system faster. It throws away work, and the kernel rebuilds the cache on demand at the price of disk reads.

When low available is a real problem

Low free is normal. Low available is not. Three situations to look for:

  • available is a small fraction of total and Swap used is growing. The working set no longer fits.

  • Shmem or a tmpfs mount holds most of the memory. That is not reclaimable cache, and a program that needs the space will trigger swapping or the OOM killer instead of cache eviction.

  • A container limit. Inside a cgroup, free still shows the host's numbers because it reads host /proc/meminfo. The container's limit lives in memory.max and memory.current under its cgroup directory, and the OOM killer acts on those.

For the swapping case, vmstat 1 shows si and so columns, the pages swapped in and out per second. Sustained non-zero so while available is low means real pressure. A single burst after boot does not.

The rule we follow when reading a memory report: ignore free, read available, then look at Swap. If the first is healthy and the last is quiet, the machine is fine however full the middle column looks.

Share

Keep reading

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.