Skip to content

32. Swap Space

Swap is a dedicated region of disk/SSD acting as RAM overflow — active pages stay in RAM, inactive ones get pushed to swap.

Where it lives: Linux uses either a dedicated swap partition (raw, faster) or a swap file inside the filesystem (flexible, resizable — used by modern Linux/WSL, /swapfile). Windows: C:\pagefile.sys. macOS: /private/var/vm/swapfile0, etc.

Full memory hierarchy (fast → slow): registers (ns) → L1/L2/L3 cache (ns) → RAM (~100ns) → swap (ms). Swap is roughly 10,000× slower than RAM — a last resort, not a feature.