How Virtual Memory Works
Why every program thinks it owns all of RAM.
Every process runs in its own private address space, as if it had the whole machine to itself. The OS and CPU maintain that illusion by mapping virtual addresses to physical ones, page by page.
Legend — how to read this diagram
Translating an address
- Virtual address. Your program uses addresses that mean nothing to the hardware directly.
- Page table. The OS keeps a map from virtual pages to physical frames.
- TLB. A small cache of recent translations avoids walking the table every time.
- Page fault. If a page isn't in RAM, the OS loads it from disk and retries.
What the illusion buys you
Isolation. One process can't read another's memory — different maps.
Overcommit. Programs can use more address space than physical RAM, backed by disk.
Sharing. Read-only pages (like libraries) map into many processes once.
Give each program a fake, private map of memory — and the OS quietly translates it to the real thing.
The same clear explainers, delivered weekly. No spam, unsubscribe anytime.
Subscribe free →120+ page production guide: local LLMs, fine-tuning, RAG, and domain-specific AI.
Get the guide →AI implementation, fine-tuning and RAG done right. Free 30-minute strategy call.
Book a call →