Virtual Memory
The problem
Multiple processes need to use memory addresses without stepping on each other or on the OS itself, and programs are often written as if they have access to more memory than physically exists — virtual memory gives every process its own private, seemingly-contiguous address space, backed by a translation layer to real physical memory.
Why now
Processes and threads established that each process is isolated, but not how that isolation is actually enforced at the memory-address level. Number systems and bases already explained how addresses are just numbers; virtual memory is the mechanism that remaps those numbers so two processes can both believe they own address 0x1000 without conflict.
Mental model
Every memory address a program uses is fake — a virtual address the CPU's memory management unit translates to a real physical address via a page table, invisibly, on every access. This indirection is what makes process isolation, memory overcommit (swapping unused pages to disk), and giving every process a clean address space starting at zero all possible at once.
Requires
- Processes & ThreadsOperating Systems
Virtual memory is the specific mechanism that enforces process memory isolation described in processes-and-threads; you need the isolation goal before the translation mechanism that achieves it makes sense.
- Number Systems & BasesMathematical Thinking
Addresses are numbers, and address translation (virtual to physical) is arithmetic over those numbers organized into fixed-size pages — positional number reasoning is the direct substrate here.
Unlocks
Used in
- Every modern OS's memory isolation between processes
- Swap space / paging to disk when physical memory is exhausted
- Memory-mapped files (mmap) — files presented as if they were memory
- Understanding segmentation faults as invalid virtual-to-physical translations
Projects
- Diagram how two processes can each use virtual address 0x1000 simultaneously without collision, showing the page table translation for each
- Trigger and interpret a segmentation fault from an intentionally invalid memory access, and explain what happened at the virtual memory layer
Examples
- Two running instances of the same program each believe their code starts at the same virtual address, translated to different physical addresses
- A segmentation fault is the CPU reporting that a virtual address has no valid translation to physical memory
Resources
Mastery checklist
- I can explain the difference between a virtual and a physical memory address
- I can explain, at a high level, how a page table translates addresses
- I can explain why virtual memory enables process isolation
- I can explain what a segmentation fault indicates about the failed memory access