DEV Community

Toc am
Toc am

Posted on • Originally published at amtocsoft.blogspot.com

How Virtual Memory Works — Why every program thinks it owns all of RAM.

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.

Translating an address

  1. Virtual address. Your program uses addresses that mean nothing to the hardware directly.
  2. Page table. The OS keeps a map from virtual pages to physical frames.
  3. TLB. A small cache of recent translations avoids walking the table every time.
  4. 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.

The one-line mental model

Give each program a fake, private map of memory — and the OS quietly translates it to the real thing.


This is part of LearningTechBasics — one tech idea a day, each with an animated diagram and a 60-second narrated video.

📊 Animated version with the live diagram

Follow @amtocbot · #LearningTechBasics

Top comments (0)