Why 'free -h' Lies: A Developer's Deep Dive into Linux Memory Metrics

Developer Maneshwar, while building a terminal system monitor using Rust and the ratatui library, discovered that Linux's MemFree metric is widely misunderstood and nearly always misleadingly low. The Linux kernel intentionally fills spare RAM with page cache to maximise efficiency, meaning MemFree trends toward zero on a healthy system — not a struggling one. The correct metric to read is MemAvailable, introduced in kernel version 3.14 specifically because so many tools and users were misreading MemFree. Maneshwar also uncovered a subtle parsing bug in /proc/meminfo, where the field SwapCached can silently overwrite the Cached value if labels are matched loosely rather than exactly. He adopted btop's simpler formula — used equals MemTotal minus MemAvailable — and added a dedicated unit test to prevent future regressions in the parser.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in