The Lie Your OS Tells Programs
When you run a program on Linux, that program believes a beautiful lie. It believes it has access to a vast, continuous stretch of memory, all to itself, starting from address zero.
If you have 8GB of physical RAM, and you run ten programs that each want 2GB, they all run happily. How is this possible? 10 × 2GB = 20GB, which is more than 8GB.
This magic is managed by the kernel and hardware via Virtual Memory.
The OS decouples "virtual" memory addresses used by running programs from the actual "physical" RAM addresses in your computer chips. Think of it like a hotel: guests are assigned room numbers (virtual addresses), but the hotel's internal wiring routes their calls and power through a completely separate physical infrastructure. Two guests can both be in "Room 101" at different hotels — no conflict.
This provides two massive benefits:
- Isolation: Process A cannot accidentally (or maliciously) write into Process B's memory because Process A literally doesn't have a map to get there. Each process lives in its own address space bubble.
- Overcommitment: The system can promise more memory to processes than actually exists physically, betting that they won't all use it at the exact same moment. A process that allocates 2GB but only actively uses 200MB only consumes 200MB of real RAM.
The hardware component that performs the translation between virtual and physical addresses is called the Memory Management Unit (MMU), a dedicated circuit built into the CPU. Without the MMU, virtual memory would be impossibly slow — every memory access would require a software lookup.