Virtual Memory Fundamentals: Address Translation & Process Isolation
Address Translation Mechanics
The CPU divides virtual addresses into page number and offset. A 4 KB page uses 12 bits for offset, remaining bits for page number. The page table maps virtual page numbers to physical frame numbers. The MMU (Memory Management Unit) performs this translation on every memory access.
Page tables can be huge. A 48 bit virtual address space with 4 KB pages needs 2^36 entries. At 8 bytes each, that is 512 GB just for page tables. Multi level page tables solve this: only allocate table entries for memory regions actually used.
TLB: The Translation Cache
Page table lookups hit RAM. That would double memory latency if done for every access. The TLB (Translation Lookaside Buffer) caches recent translations. Modern CPUs have 64 to 1536 TLB entries. A TLB hit adds 1 cycle. A TLB miss triggers page table walk: 4 memory accesses for a 4 level table, roughly 200 nanoseconds.
TLB efficiency dominates memory performance for large working sets. With 4 KB pages and 1024 TLB entries, you cache 4 MB of address translations. Access patterns spanning more than 4 MB cause frequent TLB misses. Each miss costs 50x a hit. This is why huge pages matter for big data workloads.
Process Isolation Guarantees
Each process has its own page table. Virtual address 0x1000 in process A maps to different physical memory than 0x1000 in process B. A bug in one process cannot corrupt another's memory. The CPU enforces this in hardware. No software can bypass it without kernel privileges.