Virtual Memory

Every process believes it has the whole machine's memory to itself, starting at address zero, contiguous and private — and none of that is literally true. Virtual memory is the elaborate illusion the OS and hardware maintain to make it true enough, and it's simultaneously what gives processes isolation, what lets you run programs bigger than RAM, and the reason a stray pointer segfaults instead of corrupting another program.

The process post said each process has its own private address space. Virtual memory is how that’s possible — one of the most important and elegant OS mechanisms. It gives each process the illusion of its own large, private, contiguous memory, while the OS and hardware map that onto the real physical RAM (and disk) shared by everyone. This post covers what virtual memory is, address translation and paging, why it’s so valuable (isolation, the illusion of abundant memory), and what it means for engineers. It underpins process isolation and a lot of system behavior.

The illusion: private, contiguous, large

Every process operates on virtual addresses, not physical ones. From the process’s view (the address space from the process post), it has:

But physical RAM is a single, finite, shared resource. Virtual memory is the mechanism that reconciles these: each process gets its own virtual address space, and the OS + hardware map virtual addresses to physical memory (wherever it actually is). The process uses virtual addresses; the hardware translates them to physical addresses on every access, transparently. This translation is what makes the illusion — private, contiguous, large per-process memory — real on top of shared, finite, fragmented physical RAM.

Address translation and paging

How does the mapping work? Through paging. Memory (both virtual and physical) is divided into fixed-size chunks called pages (virtual) and frames (physical), typically 4KB. The OS maintains, per process, a page table that maps the process’s virtual pages to physical frames:

Process's virtual address  →  [ page table ]  →  physical address
   (virtual page number)         (per-process map)    (physical frame)

Process A: virtual page 5 → physical frame 12
Process B: virtual page 5 → physical frame 88   ← same virtual page, different physical frame
   → the page table is what makes each process's memory private and mapped independently

Paging with per-process page tables is the machinery: it makes each process’s memory independent (separate page tables → separate mappings → isolation) and flexible (virtual contiguity over scattered physical frames). Translation on every access is the constant, hardware-accelerated work that sustains the illusion.

Why virtual memory is so valuable

Virtual memory isn’t just an implementation detail — it provides several profound benefits that shape everything above it:

So virtual memory gives isolation (safety), the appearance of more memory than exists (via disk), simplicity, and flexibility — a lot of value from one mechanism. It’s arguably the OS’s most important single abstraction.

What it means for engineers

Virtual memory explains a range of real behaviors:

Virtual memory is the elegant illusion — private, contiguous, large per-process memory over shared, finite physical RAM — maintained by per-process page tables and hardware translation, giving isolation, the appearance of abundant memory, and simplicity. It’s foundational to process isolation and explains segfaults, OOM/thrashing, and memory-performance behavior. The next post drills into why memory performance varies so much — the memory hierarchy and caching.

Key takeaways

Further reading

Sources & References