free From Zero: Read the Memory Ledger and Stop Being Fooled by the free Column
Is there enough memory? free answers the question — and the column most people read is the least useful one. This guide runs every command for real on procps-ng free 4.0.4: total, used, free, shared, buff/cache and available, -w, -t, --si, -s sampling, and a live 200MB allocation that shows the kernel handing cache back. The rule to remember: judge memory by available, never by free.

Is there enough memory — that is the first question you ask when a server slows down, and also the easiest one to read wrong. free answers it. Its name means "idle," and its manual page defines it in one line: "Display amount of free and used memory in the system." It belongs to the procps-ng suite, the same toolbox as ps, top, and vmstat, and it does exactly one thing: it opens up the memory ledger for you to read. Every command in this guide was run for real on procps-ng free 4.0.4, and the output is pasted verbatim.
Check the version first, then start. The demo runs on this sandbox, which has 7.7Gi of memory, and the numbers change on every run — other processes are allocating and releasing memory all the time — so the text quotes structure and direction of change, and the exact numbers are in the transcript:
$ free --version free from procps-ng 4.0.4 exit=0
A bare free with no options uses KiB (1,024 bytes) as its unit, and the numbers come out big and hard to read. The first command to learn is free -h, where -h stands for human-readable: it scales everything to the shortest three-digit unit automatically:
$ free -h
total used free shared buff/cache available
Mem: 7.7Gi 7.1Gi 137Mi 82Mi 912Mi 692Mi
Swap: 1.0Gi 129Mi 894Mi
exit=0
The table has only two rows, but it holds the whole memory ledger. The first row, Mem, is physical memory. The second row, Swap, is the swap area. The columns, left to right, are total, used, free, shared, buff/cache, and available. On this demo machine, physical memory totals 7.7Gi, with 7.1Gi used, only 137Mi free, 912Mi in buffers and cache, and 692Mi available. Swap totals 1.0Gi, with 129Mi used and 894Mi free. One point matters more than the rest: the free column shows only 137Mi, but available shows 692Mi. The two numbers are different, and available is the memory you can actually use. Why that is so gets its own section below.
Start with the precise definition of each column, because the manual page defines every one of them exactly. total is "total usable memory," taken from MemTotal and SwapTotal in /proc/meminfo, minus a few reserved bits and the kernel binary code. used has the definition most people get wrong: the manual page says "Used or unavailable memory (calculated as total - available)." Used is computed, not measured directly: total minus available. free is "unused memory," from MemFree and SwapFree. shared is "memory used (mostly) by tmpfs," from Shmem in /proc/meminfo. buffers is memory used by kernel buffers, from Buffers. cache is memory used by the page cache and slabs, from Cached and SReclaimable. buff/cache is the sum of buffers and cache. available is an "estimation of how much memory is available for starting new applications, without swapping," from MemAvailable — provided directly by kernels 3.14 and above, emulated on kernels 2.6.27 and above, and otherwise the same as free.
The difference between available and free is the most important lesson in the whole free command. free is "memory nobody is using right now." available is "memory a new program can get when it starts." The gap between them is cache that can be reclaimed at any moment: the kernel puts idle memory to work as a file cache, and when a program needs memory, the cache gives it back immediately. So a free column of 137Mi does not mean the machine is nearly out of memory. The available figure of 692Mi is the real water level. To judge whether memory is sufficient, look at available, never at free. A free value close to zero is normal: the Linux design philosophy is that idle memory is wasted memory, so the kernel puts all of it to work as cache until a program needs it back.
The buff/cache column deserves its own explanation. It is the sum of buffers (kernel buffers) and cache (the page cache). In the demo it is 912Mi, more than a tenth of total memory. The page cache is how the kernel speeds up file reads: the contents of files you have read stay in memory, so the next read does not touch the disk. Its defining property is that it is reclaimable: when memory gets tight, the kernel drops cache first and hands the memory to programs. So a large buff/cache is not a bad sign. It is a good one. It means the kernel is using idle memory to make things faster. It only becomes worth worrying about when a large part of it cannot be reclaimed — files in tmpfs, for example, or memory that has been locked. To see buffers and cache separately, use -w, the wide mode:
$ free -h -w
total used free shared buffers cache available
Mem: 7.7Gi 7.1Gi 137Mi 82Mi 20Ki 911Mi 692Mi
Swap: 1.0Gi 129Mi 894Mi
exit=0
In wide mode, buffers and cache become two columns: buffers is only 20Ki, cache is 911Mi. On this machine, buff/cache is almost entirely page cache, and the kernel buffers themselves are negligible. That ratio is typical on most machines: buffers are usually tiny, and cache is the big one. The manual page notes that wide-mode lines run longer than 80 characters. That is fine on a terminal, but worth knowing when you parse the output in a script.
The unit options are the other half of the basics. The default is KiB (-k). -m is MiB, -g is GiB, -b is bytes. The demo's -m output reads:
$ free -m
total used free shared buff/cache available
Mem: 7934 7241 137 82 912 692
Swap: 1023 129 894
exit=0
7,934 MiB is 7.7Gi. The numbers match the -h table; only the unit differs. -h is the most common choice, because it picks the unit for you. -m is the most common choice in monitoring scripts, because the numbers are integers with no unit suffix, which makes them easy to parse. There is also a set of power-of-1000 units: --kilo, --mega, --giga, --tera, --peta, or the umbrella option --si, which uses powers of 1000 instead of powers of 1024. In the demo, free -h --si reports 8.3G total and 7.6G used. The same physical memory is 7.7Gi by powers of 1024 and 8.3G by powers of 1000. The "8G of memory" on a vendor's spec sheet and the "7.7Gi" the system reports are the same thing in different units. Vendors count in thousands, systems count in 1,024s. That gap has existed since the day you bought the machine.
-t, the total option, adds a summary line at the bottom of the table:
$ free -h -t
total used free shared buff/cache available
Mem: 7.7Gi 7.1Gi 137Mi 82Mi 912Mi 692Mi
Swap: 1.0Gi 129Mi 894Mi
Total: 8.7Gi 7.2Gi 1.0Gi
exit=0
The Total line is Mem plus Swap: 8.7Gi total, 7.2Gi used, 1.0Gi free. Note that only the total, used, and free columns have numbers on that line. shared and buff/cache are blank, because those two concepts belong to physical memory; swap has neither. The summary line is useful for a quick report: "this machine has 8.7G of memory in total, 7.2G used." One sentence says it all.
-s, seconds, makes free repeat its output every few seconds. -c, count, says how many times to print, and it requires -s. In the demo, free -h -s 1 -c 2 prints once a second, twice in total, and the available figure moves from 691Mi to 712Mi between the two samples. One second apart, and the number has already changed by 21Mi. That is why the text never treats a specific number as fixed: memory is alive, and it changes every second. The -s delay can be a floating-point number — the manual page says you can use either . or , as the decimal point. -L, line, squeezes the output onto a single line, and it is often combined with -s, so a monitoring log gets one record per line.
Where do free's numbers come from? The manual page says it plainly: it parses /proc/meminfo. The demo script reads that file directly:
$ grep -E 'MemTotal|MemFree|MemAvailable|Buffers|Cached|SwapTotal|SwapFree' /proc/meminfo MemTotal: 8124612 kB MemFree: 161740 kB MemAvailable: 729616 kB Buffers: 20 kB Cached: 812056 kB SwapCached: 18748 kB SwapTotal: 1048572 kB SwapFree: 915728 kB exit=0
Check them against the table: MemTotal of 8,124,612 kB is 7.7Gi, MemFree of 161,740 kB is about 137Mi, MemAvailable of 729,616 kB is about 692Mi, Buffers of 20 kB matches the 20Ki in the wide-mode output, and Cached of 812,056 kB roughly matches the 911Mi cache column — the cache column also includes SReclaimable, not just Cached. Once you can read /proc/meminfo, you can see where every column of free comes from. free is essentially a formatted view of that file. For finer detail — Slab, PageTables, AnonPages — read the full /proc/meminfo. What free does not show is all in there.
Now the core of the demo: allocate a real 200 MB and watch the available column move. The script records the numbers before allocating, then starts a background Python process that allocates 200 MB and touches every page — without touching the pages, Linux's on-demand allocation would not actually take the memory — holds it for eight seconds, prints free once while it is held, and prints it again after the process exits:
$ free -h # before allocating 200 MB
total used free shared buff/cache available
Mem: 7.7Gi 7.1Gi 157Mi 82Mi 912Mi 712Mi
Swap: 1.0Gi 129Mi 894Mi
exit=0
$ free -h # while 200 MB is held
total used free shared buff/cache available
Mem: 7.7Gi 7.2Gi 170Mi 81Mi 729Mi 523Mi
Swap: 1.0Gi 152Mi 871Mi
exit=0
$ free -h # holder exited: the memory comes back
total used free shared buff/cache available
Mem: 7.7Gi 7.0Gi 356Mi 81Mi 711Mi 718Mi
Swap: 1.0Gi 153Mi 870Mi
exit=0
Read the three tables. Before the allocation, available is 712Mi. While the 200 MB is held, available falls to 523Mi — a drop of 189Mi, essentially the 200 MB that was allocated, with the small difference coming from other processes moving at the same time. After the holder exits, available is back to 718Mi. The memory came back. Two more details are worth noting. First, buff/cache fell from 912Mi to 729Mi: to make room for the 200 MB, the kernel reclaimed about 180Mi of page cache on its own. That is the "cache is reclaimable" lesson, demonstrated live. Second, Swap used rose from 129Mi to 152Mi: when memory got tight, the kernel moved some little-used anonymous memory out to the swap area. Together, the two effects are the daily routine of Linux memory management: when memory is needed, reclaim cache first, and only then swap out to disk.
The Swap row deserves its own explanation. Swap is an area on disk. When memory runs short, the kernel moves little-used memory pages out to disk, freeing physical memory for programs that need it more. In the demo, Swap totals 1.0Gi with 129Mi used, which says this machine has been tight on memory before and swapped something out. Swap used being above zero for a long time is not necessarily bad: the kernel proactively moves pages that have not been touched for a long time out to disk, making room for cache. What should worry you is Swap used climbing steadily while available keeps falling. That says physical memory is genuinely insufficient and the kernel is surviving on disk. Swap lives on disk, orders of magnitude slower than memory, and once a program starts swapping in and out heavily — thrashing — performance falls off a cliff. The right way to read Swap is by its trend, not by a single sample.
-v, the committed option, is the one in the manual page most often misunderstood. It adds a Comm line. In the demo:
$ free -h -v
total used free shared buff/cache available
Mem: 7.7Gi 7.0Gi 356Mi 81Mi 711Mi 718Mi
Swap: 1.0Gi 153Mi 870Mi
Comm: 4.9Gi 2.9Gi 1.9Gi
exit=0
The three numbers on the Comm line are: the memory commit limit of 4.9Gi, the committed amount of 2.9Gi, and the uncommitted amount of 1.9Gi. "Committed" means the total memory programs have asked the kernel for — asked for, not actually used. Linux allows overcommit by default: a program may ask for more memory than physically exists, the kernel says yes for now, and the memory is only really allocated when the program writes to it. The manual page makes a point of this: if overcommit is enabled, the free value can temporarily appear negative. That is not a bug. It is an effect of overcommit: the system has promised more memory than its virtual address space totals, and the negative value shows how far the over-allocation goes. Once you understand this line, you understand why a program can succeed in allocating memory and then get killed by the OOM killer when it actually tries to use it: the kernel said yes at request time, and found nothing there at use time.
The OOM killer deserves a mention of its own, because it is the link between free's numbers and whether a program lives or dies. When available is exhausted, cache cannot be reclaimed any further, and swap is full, the kernel starts the OOM killer, picks a process, and kills it to free memory. The victim is usually the process using the most memory, but not always — the kernel scores candidates by a set of rules. If your program vanishes when memory runs low and the log shows "Out of memory: Killed process," that was the OOM killer. The way to prevent it is not to stare at the free column. It is to set a memory limit on the important services — cgroup's memory.max — so a runaway process is contained before the kernel has to pick a victim to kill.
Finally, place free in the toolbox alongside the guides already published in this series. df looks at disk space and answers "is the disk full." free looks at memory and answers "is there enough memory." ps looks at individual processes and answers "who is using how much memory." top is a live-updating process table and answers "who is eating memory right now." vmstat looks at the whole system's resource trend and answers "how are memory, CPU, and IO moving together." When a machine slows down, start with free -h to see whether available is sufficient, then sort top by memory to find the big consumers, then use vmstat to see whether the machine is swapping in and out. free is the first step, not the whole answer. It tells you whether memory is sufficient. It does not tell you who ate it. That is ps and top's job.
Here is a daily cheat sheet you can copy as-is. The machine is slow: run free -h first and look at the available column. If it is sufficient, memory is not the problem; go check CPU and disk. If it is not, dig deeper. For a finer view, free -h -w splits buffers and cache, so you can see whether cache is the big consumer. To watch over time, free -h -s 1 -c 5 refreshes once a second, five times, and shows whether available is rising or falling. For a monitoring script, free -m gives integers with no unit suffix, which parse cleanly; free -h -L gives one record per line. To see the commit situation, free -h -v shows the Comm line with the committed amount and the limit. To confirm where a number comes from, grep MemAvailable /proc/meminfo reads the kernel's raw data directly.
A few more traps worth collecting. First: looking at free instead of available. A free value near zero is normal. An available value near zero is genuinely dangerous. Second: treating buff/cache as "occupied memory." Cache is reclaimable; the kernel returns it on its own when memory gets tight. Third: panicking because Swap used is above zero. The kernel proactively swaps out pages it does not use. Swap having a nonzero value does not mean memory is insufficient. Watch the trend. Fourth: comparing numbers across different units. 7.7Gi and 8.3G are the same memory. Do not compare the -h numbers with the --si numbers directly. Fifth: free's numbers change every second. When a script makes a decision from them, leave a margin and average several samples. Do not decide from a single sample. Sixth: free only sees the whole machine. To see how much memory one process uses, use ps or /proc/<pid>/status. That is another tool's job.
The used column's arithmetic deserves a closer look, because it is the most often misread. The manual page states it plainly: used = total - available. Used is not measured directly. It is total minus available. And available, by definition, includes cache that can be reclaimed at any moment. So the used number is naturally inflated: it lumps together "memory programs really occupy" and "memory temporarily lent to cache that can come back at any time." In the demo, used is 7.1Gi, which sounds as if memory were nearly exhausted. But available is still 692Mi, and the machine is nowhere near the danger line. When reading free's output, the used column can mostly be ignored. It exists so that the equation total = used + available holds. It does not tell you how tight memory is. Only available does that.
The shared column also deserves its own explanation, because it connects to another guide in this series. The manual page says shared is "memory used (mostly) by tmpfs," from Shmem in /proc/meminfo. tmpfs is a filesystem that keeps files in memory. /tmp and /dev/shm are tmpfs on many systems. Write a 100 MB file into /tmp and the shared column rises by about 100 MB, while physical memory falls by the same amount. The df guide showed that /tmp in this sandbox is a 512 MB tmpfs. That 512 MB ceiling is carved out of physical memory. So "the disk is full" and "memory is full" are the same thing on tmpfs: writing a large file into /tmp takes disk space, which df can see, and memory, which free's shared column can see. When investigating a memory problem, do not forget to look for large forgotten files in /tmp.
How should monitoring thresholds be set? That is where free's numbers turn into practice. There is no universal number, but three rules of thumb help. First, watch available as a share of total: below 10% for a sustained period deserves attention, and below 5% deserves action — add memory, or find the process eating it. Second, watch the trend of Swap used: a single sample above zero means nothing, but a steady climb over a week says physical memory has been living on the edge. Third, watch the direction of available: free -h -s 60 -c 10 samples once a minute, ten times. If available keeps falling, that is a memory leak or rising traffic. If it stays flat, that is normal fluctuation. Write the alert rule on available, not on free. A rule on free is an alert on "the kernel is using cache normally," and it will wake you up at night for nothing.
The manual page has a few more options this guide does not demonstrate in full; it is enough to know they exist. -l, lohi, shows detailed low and high memory statistics — a leftover from the 32-bit era, barely used on 64-bit machines. -c must be used together with -s; using -c alone is an error. The -s delay can be a floating-point number, and the manual page says you can use . or , as the decimal point. --tebi and --pebi are TiB and PiB units, for machines with that much memory. --help and --version are standard on every procps tool. If you forget what an option means, run free --help first, then the manual page.
By the way, free's output is nearly identical across distributions. It is part of procps-ng, and procps-ng ships with every mainstream Linux distribution. Ubuntu, Debian, CentOS, Arch — the options and output format are basically the same everywhere. Learn it once, use it everywhere. That is also why this series favors these basic tools: they do not chase trends, they do not get discontinued, and they do not change their interfaces. Ten years from now they will look the same.
One more environment where free misleads beginners: containers. Inside a Docker container, free reads /proc/meminfo, which describes the host machine, not the container. If the host has 64 GiB and your container is limited to 2 GiB by a cgroup, free will still report 64 GiB total. The number is not wrong — it is the host's number — but it is not your container's number. To see a container's real limit, read the cgroup files: memory.max for the ceiling and memory.current for what the container is actually using. The same caution applies to virtual machines with memory ballooning, where the "total" can change while the machine runs. free tells the truth about the machine it runs on. Make sure you know which machine that is.
There is a famous misunderstanding behind all of this, summed up by the old website linuxatemyram.com: "Linux ate my RAM." A new user runs free, sees free at nearly zero, and concludes the system has eaten all the memory. What actually happened is the opposite. Linux used the idle memory as a disk cache, which makes everything faster, and it will hand the memory back the moment a program needs it. The confusion comes from reading the wrong column. The kernel developers knew this would confuse people, which is exactly why the available column was added to /proc/meminfo in kernel 3.14 and to free's output: it is the number that answers the question people are actually asking. If you remember only one thing from this guide, remember this: free means almost nothing, available means almost everything.
For readers who like to see the raw data, /proc/meminfo is worth opening once in full. Beyond the fields free shows, it lists AnonPages (anonymous memory, the kind programs allocate for their own data), Slab (kernel data structures), PageTables, KernelStack, and dozens more. Each field is a window into a different part of the memory system. You do not need to memorize them. But the next time a machine behaves strangely, knowing that the answers are sitting in a plain text file — readable with cat, greppable with grep, free for the taking — is the difference between guessing and measuring.
Boundary note: this guide covers only free — the total, used, free, shared, buffers and cache, and available figures for whole-machine physical memory and swap. It does not cover per-process memory use (that is ps's territory), live-updating process tables (that is top's territory), or memory trends and swap-in and swap-out activity (that is vmstat's territory). Boundaries against published guides: the df guide covers disk space, the process management guide covers ps, kill, and signals, and the lsof guide covers processes, files, and port usage. free is different from all of them: it only reads the whole-machine ledger in /proc/meminfo. The demo in this guide runs in a sandbox: the sandbox has 7.7Gi of memory and 1.0Gi of swap. The demo script allocates a real 200 MB in a background Python process, touches every page, holds it for eight seconds, watches the available column move, and then releases it. The transcript's exact numbers change on every run, because other processes are allocating memory too; the text quotes structure and direction of change, and the exact values are in the transcript. The demo script ends by printing --- done (no process left, no file created) ---, meaning the holder process has exited and no file was left behind. The available-column demo values (712Mi before allocation, 523Mi while held, 718Mi after release), the buff/cache reclaim (912Mi to 729Mi), and the Swap change (129Mi to 152Mi) are the measured values from that run.
Comments (0)
Sources
Related articles
How many lines, how many words, how many bytes — wc answers all three, and it is easy to get all three wrong. This guide runs every command for real on GNU coreutils wc 9.4: -l counts newlines (not lines), -c and -m diverge on Chinese text, --total=only, multi-file totals, and piping — with output pasted verbatim and the two classic traps explained.
df answers one question: how much space is left on each file system. This guide runs every command for real on GNU coreutils df 9.4 — a 100M file moving Use% from 2% to 21%, inodes with df -i, and the classic trap: a deleted-but-open file keeps its space until the process exits — with output pasted verbatim.
ss reads the kernel's socket table: who is listening, what state each connection is in, which process holds the socket. This guide runs every command for real on iproute2 ss 6.1.0 — a live http.server on 127.0.0.1:18080, LISTEN vs ESTABLISHED, state filters, ss -s, Unix sockets — with output pasted verbatim.