Fundamentals 14 min read

Understanding Linux Page Cache and Memory Metrics: From free to /proc/meminfo

This article explains how Linux reports memory usage, covering the free command output, the evolution of buffer and page caches, detailed /proc/meminfo fields, shared memory accounting, kernel memory statistics, huge pages, and per‑process metrics such as smaps and top.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Understanding Linux Page Cache and Memory Metrics: From free to /proc/meminfo

Starting with the free command

The free command shows a snapshot of memory usage. Its columns are:

Total – total physical RAM (derived from /proc/meminfo).

Used – memory in use, excluding buffers and cache.

Free – unused memory, also excluding buffers and cache.

Shared – size of shared memory, mainly tmpfs.

Buffers / Cache – memory used for block device buffers and page cache.

Available – an estimate of memory that can be allocated without swapping; roughly free + buffers/cache on kernels 3.14 and newer, but not an exact figure.

Buffers and cached memory are not always fully reclaimable; the available field provides a best‑effort approximation.

Historical buffer vs. page cache

Before Linux 2.4.10 the kernel maintained two separate caches: Buffer Cache for block‑device metadata and Page Cache for file data. After 2.4.10 the buffer cache concept was removed and all such data resides in the page cache, with pages tracked via the buffer_head structure and reported under the buffers metric.

/proc/meminfo details

Most memory‑related commands read values from /proc/meminfo. Important global fields include:

MemTotal – total usable RAM (physical RAM minus reserved and kernel code).

MemFree – total unused RAM.

MemAvailable – kernel’s estimate of reclaimable memory (includes free RAM, reclaimable caches, and parts of Slab).

User‑space pages are divided into:

File‑backed pages (e.g., file data, executable code) – stored in the page cache and can be written back to disk (page‑out).

Anonymous pages (heap, stack, etc.) – swapped out to the swap area when memory is scarce.

All page‑cache pages are file‑backed; anonymous pages are swapped out via Swap.

Shared memory accounting

Linux implements shared memory via SystemV, POSIX, and anonymous tmpfs mechanisms. These pages are counted under Cached and Mapped, not under AnonPages. If such pages are locked with mlock(), they appear in the Unevictable list.

Kernel memory statistics

Slab – memory used by the kernel slab allocator.

SReclaimable – reclaimable portion of the slab.

SUnreclaim – non‑reclaimable slab memory.

KernelStack – memory allocated for kernel stacks.

PageTables – size of page tables.

NFS_Unstable – NFS pages pending commit.

Bounce – bounce buffers for devices that can only access low memory.

WritebackTmp – FUSE write‑back buffer size.

VmallocTotal / VmallocUsed / VmallocChunk – vmalloc area statistics.

HardwareCorrupted – memory detected as faulty.

HugePages

Transparent HugePages (THP) are reported as AnonHugePages. Dedicated huge pages have separate counters: HugePages_Total, HugePages_Free, HugePages_Rsvd, HugePages_Surp, and Hugepagesize. THP usage is included in a process’s RSS/PSS, while dedicated huge pages are not.

Process‑level statistics

VSS (Virtual Set Size) – total virtual memory size.

RSS (Resident Set Size) – physical memory actually resident, including shared libraries.

PSS (Proportional Set Size) – RSS with shared library memory divided among processes.

USS (Unique Set Size) – memory unique to the process, excluding shared parts.

/proc/{pid}/smaps

The /proc/{pid}/smaps file provides per‑mapping details. Key fields are:

Size – mapping size.

Rss – resident memory size.

Pss – proportional set size.

Shared_Clean / Shared_Dirty – shared clean/dirty memory.

Private_Clean / Private_Dirty – private clean/dirty memory.

Referenced – pages marked as referenced.

Anonymous – anonymous memory size.

AnonHugePages – THP usage.

Swap – swapped‑out size.

KernelPageSize / MMUPageSize – kernel and MMU page sizes.

Locked – memory locked via mlock().

VmFlags – page flag bits (see kernel documentation).

Because Rss includes shared libraries, summing it across processes double‑counts shared memory; Pss avoids this by proportionally allocating shared pages.

The latest kernel documentation adds a smaps_rollup entry that aggregates Pss_Anon , Pss_File and Pss_Shmem for clearer per‑process memory usage.

top command

The top utility shows several memory columns:

VIRT – virtual memory size (code, data, shared libraries, swapped pages, and unmapped memory).

RES – resident memory size (includes shared libraries).

SHR – shared memory size (not all of which is resident).

SWAP – swapped‑out memory size.

CODE – size of executable code.

DATA – size of data + stack.

USED – total memory in use (RES + SWAP).

These metrics together give a comprehensive view of how Linux accounts for memory at both the system and process levels.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Memory ManagementLinuxsystem-monitoringpage cacheprocfs
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.