The illusion of private memory
Each process sees a contiguous virtual address range (typically 0 to 2⁴⁷–1 on 64-bit Linux user space). Code, heap, stack, mmap regions, and shared libraries occupy separate virtual ranges. Process A at virtual address 0x1000 maps to completely different physical frames than process B at 0x1000 — isolation by design.
Typical layout (conceptual)
| Region | Grows | Contents |
|---|---|---|
| Text (code) | Fixed | Read-only executable instructions |
| Data/BSS | Fixed | Initialized and zero-initialized globals |
| Heap | ↑ upward | malloc allocations |
| mmap arenas | Variable | Shared libs, file mappings, large allocs |
| Stack | ↓ downward | Local variables, return addresses |
ASLR randomizes base addresses to frustrate exploit chains — /proc/<pid>/maps shows the actual layout.
Why virtual addresses exist
- Isolation — processes cannot read each other's memory without
mmap(MAP_SHARED)orptrace. - Simpler linking — every binary can assume it loads at the same virtual base.
- Sparse address spaces — reserve 1 TB virtual for a memory-mapped file without committing physical RAM.
- Overcommit — allocate virtual pages now, back with physical frames on first touch.
Senior-level signal
A segfault is the kernel killing your process for an invalid virtual access — unmapped page, write to read-only, stack overflow into guard page. dmesg may show the faulting address; compare against /proc/<pid>/maps to distinguish null-pointer bugs from stack exhaustion.
Where this goes next
Paging & Page Tables explains the data structures that translate those virtual addresses into physical frames — and how page faults make demand paging work.
Further Reading
Hands-On Tasks (Optional)
Low-setup exercises on your local machine. No autograding — the goal is to build intuition, not pass a test.
- Inspect a process memory map15m
Pick a PID (`pgrep -l python` or any long-running process). On Linux: `cat /proc/<pid>/maps | head -20`. On macOS: `vmmap <pid> | head -30`. Identify heap, stack, and mapped libraries.