The full picture
🎬 Virtual memory: TLB, page tables and page faults
1 / 5The process uses VIRTUAL addresses — a private, contiguous-looking address space. Physical RAM is a shared pool of page frames. The MMU translates every single memory access.
- Mechanically: address = virtual page number + offset; page table maps VPN→physical frame; pages are 4KB (or 2MB/1GB huge pages). Permissions (r/w/x) ride on the page table entry — that's how W^X and read-only .text are enforced.
- Overcommit is policy, not accident:
malloc/mmaphand out address space; RAM is committed on first touch (a minor fault). The bill can arrive later as the OOM killer — allocation success ≠ memory availability. - Address space layout: text, data, heap growing up, stacks, mmap region, kernel space at the top of the address space — plus ASLR shuffling bases as an exploit-mitigation.
- JVM lens:
-Xmxreserves virtual space (cheap); RSS grows as the heap is touched — why a freshly started JVM with a 30GB Xmx shows small RSS, and why 'VIRT' in top scares people needlessly.