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
/proc/meminfo: Cached, Dirty, Writeback, MemAvailableParameters & Attributes
| Name | Type | Description |
|---|---|---|
| Cached | kB counter | Aggregate cached file data accounting. |
| Dirty | kB counter | Memory awaiting writeback. |
| Writeback | kB counter | Memory currently being written back. |
| MemAvailable | kB estimate | Estimated available memory for new workloads without swapping. |
Return Value
Dynamic memory snapshot; this example checks presence, units and nonnegative values only.
Working Example
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