FreeBSD's RAM Caching Explained: Why Memory Usage Looks Off
Original: FreeBSD ate my RAM
Why This Matters
Clarifies OS-level memory management behavior relevant to any developer deploying workloads on FreeBSD systems.
Developer Bruno Croci investigated why FreeBSD reports confusing RAM usage figures across tools like fastfetch and btop. The core reason: FreeBSD aggressively caches disk data in RAM to boost performance, freeing that cache only when processes need more memory.
After migrating his site server from Ubuntu to FreeBSD, developer Bruno Croci noticed discrepancies in RAM usage between fastfetch and btop. Prompted by a Hacker News discussion and the well-known 'Linux ate my RAM' explainer, he spent weeks researching FreeBSD's memory management internals.
At the heart of the issue is FreeBSD's Virtual Memory (VM) system, which divides physical RAM into 4KiB pages and manages them across several queues: active (pages in use by userland processes), inactive (pages not recently accessed), laundry (pages queued for swap), wired (kernel-managed, non-swappable memory), and free (unused memory).
FreeBSD, like Linux, caches disk data in RAM to improve performance — analogous to how a CPU caches RAM contents. This cache is volatile: it is reclaimed immediately when processes demand more memory. Tools that report only 'used' and 'free' memory omit this nuance, making RAM appear nearly full when it is not.
Croci notes he is not an OS internals expert and invites corrections, framing the post as a research writeup for enthusiasts navigating the same confusion.