Computing Surveys · 1970 Interactive Explainer

Virtual Memory: The Illusion of Infinite RAM

In 1970, Peter Denning synthesized the principles behind one of computing’s most enduring tricks: making a cramped physical memory behave like a vast, private workspace. Instead of forcing programmers to manually shuffle code in and out of memory, the hardware and operating system collaborate to automate the illusion—as long as they obey the laws of locality and working sets.

Main Memory (RAM) ≈ Your Desk

Fast, tiny, and immediately reachable

The CPU can only read instructions and data currently sitting in main memory. In Denning’s 1970 hardware model, fetching a word from RAM takes roughly 1 microsecond—fast enough to keep pace with the processor, just like flipping open a folder sitting right on your desk.

Auxiliary Memory (Swap) ≈ The Filing Cabinet

Huge, cheap, and 10,000× slower

Everything that does not fit on the desk lives in auxiliary memory (a magnetic drum in 1970; SSD/swap space today). Walking down the hall to pull a folder from the filing cabinet takes at least 10 milliseconds—so a single trip to disk costs as much time as ten thousand desk lookups.

RAM Reference Time (δ) 1 μs Electronic access speed
Swap Transport Time (T) 10 ms 10,000× slower than RAM
Manual Folding Overhead +25–45% Extra programmer effort (Sayre)
Optimal Page Size Rule √(2cs₀) Balances slack vs. table size
Part 01 · Address Translation & Paging

Virtual Addresses Are Hotel Reservations, Not GPS Coordinates

Denning draws a sharp line between address space (the names a program uses, 0 .. n−1) and memory space (physical RAM slots, 0 .. m−1). Imagine a grand hotel where every floor holds z = 10 rooms numbered 0 through 9. If your confirmation says Room #34, you instantly know that means Floor 3, Room 4.

In virtual memory, the front desk keeps a Page Table (the address map f). It maps each virtual floor (Page p) to whichever real physical wing (Frame f) happens to be free—while your room number inside the floor (Offset w) stays completely unchanged. If that floor is locked away in storage (Present Bit = 0), the hardware triggers a Page Fault to haul it from swap disk into RAM.

1. Split Virtual Address
a = 34 → (p=3, w=4)
Page p = ⌊34 / 10⌋ = 3 Offset w = 34 mod 10 = 4
2. Front-Desk Lookup
PT[3] → Frame 1
Valid Bit = 1 · Loaded in RAM
3. Physical RAM Address
a' = 1 × 10 + 4 = 14
Offset w=4 unchanged (Artificial contiguity!)
HIT IN MAIN MEMORY (1 μs) Virtual Page 3 is sitting in Physical Frame 1. Hardware translates directly without touching swap disk.

Hotel Front-Desk Directory (Page Table)

Click Valid Bit to Evict / Load
Page p Virtual Range Present Bit Frame f

Physical RAM (4 Frames)

Non-contiguous frames
Auxiliary Swap Space (Filing Cabinet on Disk) 4 pages on disk
Part 02 · Paging vs. Segmentation

Uniform Pages Never Checkerboard—Variable Segments Do

How should an operating system carve up memory? Segmentation lets programmers group code into logical, variable-sized modules (a main loop, a growing stack, a shared math library) using two-part addresses (s, w). It feels natural—until modules come and go. Soon physical RAM gets checkerboarded with scattered free holes too small to fit the next segment: external fragmentation.

Paging solves this by forcing every block into one fixed size. Because every free frame fits every page, external fragmentation drops to zero. Its only waste is internal fragmentation: unused slack inside the very last page of a segment (on average, half a page z/2). That is why modern systems combine both, paging each logical segment under the hood.

Interactive 32 KB Memory Sandbox

Toggle modules in and out to watch checkerboarding appear
All modules fit cleanly. Try freeing two non-adjacent modules, then allocating a larger one.

Segmentation (Contiguous Variable Blocks)

Paging (8 Fixed 4 KB Frames)

Part 03 · The Principle of Locality

Programs Favor Small Neighborhoods Over Long Stretches

Virtual memory only works because real programs do not jump across RAM like confetti. Denning observed that during any interval of execution, a program concentrates its references inside a tiny, slowly changing cluster of pages. This Principle of Locality has two sides:

Temporal Locality: If you referenced a variable or loop body just now, you will likely touch it again very soon. Spatial Locality: If you just read Room #34, your next instruction or array element is almost certainly Room #35 right next door.

Memory Access Heatmap (Pages P0–P7 over Time t = 1..24)

Blue = First touch · Pink = Temporal re-use · Click any cell to inspect
Selected Memory Reference
Same-Page / Neighbor Rate
Part 04 · The Working Set Model

Keep the Last h Pages on the Desk, and Let the Rest Wait

How does an operating system know which pages belong on your desk without seeing the future? Denning’s breakthrough was the Working Set W(t, h): the set of distinct pages a program has referenced inside a backward-looking window of the last h accesses.

As long as locality holds, pages inside W(t, h) are the pages you will need next. Rather than guessing with a rigid fixed frame limit (like static FIFO or fixed-size LRU), the Working Set Principle insists that a program runs if and only if its entire working set fits in RAM—preventing needless faults during phase changes.

Reference String ω (Click any step to jump t) Trace A: Subroutine Phase Shift
Active Working Set W(t, h) = Pages in Window [t−h+1 .. t]
Working Set Size |W(t, h)|
3 pages
Denning Working Set Policy

Dynamic RAM = |W(t, h)|

Static Allocation (3 Frames) · LRU

Evicts Least Recently Used

Static Allocation (3 Frames) · FIFO

Evicts Oldest Arrived Page

Expected Working Set Size w(h) Across Window Sizes

Denning’s Theorem: w(h) is non-decreasing and concave down; marginal miss rate g(h) = w(h+1) − w(h)
Part 05 · Multiprogramming & Thrashing

Oversubscribe RAM by One Process, and the CPU Collapses

Time-sharing computers run multiple programs at once so the CPU stays busy while one program waits for I/O. But if a global allocator packs k programs into M physical frames such that each gets fewer frames than its working set, fault probability f(m) shoots upward. Because swap is α = T/δ = 10,000× slower than RAM, the CPU’s execution efficiency d(m) = 1 / [1 + αf(m)] falls off a cliff.

Denning named this collapse thrashing: the system spends 99% of its time frantically paging missing blocks back and forth while almost no useful instructions execute. The cure is the Working Set Scheduler: admit a new program only when enough unallocated frames remain for its full working set—and swap out an entire program rather than starving everyone.

CPU Useful Work (Efficiency) 89% Healthy multiprogramming
Swap Disk I/O Wait 11% Low paging traffic
Working Set Demand vs. RAM 24 / 32 Frames required (6 per proc)

CPU Utilization vs. Degree of Multiprogramming (k)

Solid Blue = Current Policy · Dashed Pink = Unchecked Global Cliff

Per-Process RAM Allocation (6 frames needed each)

Blue = Full Working Set · Pink = Starved