concepts

Page Cache — Cached File Data

The page cache keeps file-backed data in memory so buffered reads and mappings can avoid repeated storage access. Writes may update cached data first; dirty data is later written back according to filesystem and kernel policies. A successful write is not a crash-durability guarantee; use application-specific sync and error handling. File cache can often be reclaimed under pressure, but dirty or referenced data may require work before reuse. Cached in /proc/meminfo is an aggregate with documented accounting conventions (including tmpfs/shmem and excluding SwapCached); it is not a per-file cache hit counter. MemAvailable is an estimate, not simply MemFree plus Cached. Inspect these fields over time with workload context; do not drop caches on a live host to benchmark. The read-only example checks selected fields labeled kB (Linux reports these memory amounts in units of 1024 bytes), without assuming specific values or claiming measured cache hits. Example prerequisites: Linux, Bash and Python 3 standard library; run as a non-root user in a private temporary working directory. Example scope: native read-only observation. Expected output: cache and writeback counters parsed (kB). No system configuration changes.

Formal Syntax & Structure

linux syntaxlinux
/proc/meminfo: Cached, Dirty, Writeback, MemAvailable

Parameters & Attributes

NameTypeDescription
CachedkB counterAggregate cached file data accounting.
DirtykB counterMemory awaiting writeback.
WritebackkB counterMemory currently being written back.
MemAvailablekB estimateEstimated available memory for new workloads without swapping.

Return Value

Concept / observation

Dynamic memory snapshot; this example checks presence, units and nonnegative values only.

Working Example

Example Snippetlinux
python3 - <<'PY'from pathlib import Pathrows=dict(line.split(':',1) for line in Path('/proc/meminfo').read_text().splitlines())for name in ('Cached','Dirty','Writeback','MemAvailable'):    value, unit=rows[name].split()    assert int(value)>=0 and unit=='kB'print('cache and writeback counters parsed (kB)')PY
Linux Reference