Programs need more memory than physically available, and we want isolation between processes (one process shouldn’t access another’s memory). Physical RAM alone can’t provide this.
Virtual memory gives each process the illusion of a large, contiguous address space, mapped to physical RAM via paging, with unused pages stored on disk (swap).
- Each process has its own virtual address space (e.g., 4GB on 32-bit)
- Virtual pages mapped to physical frames via page table
- Pages not in RAM are stored in swap space on disk
- Access to swapped-out page causes page fault → OS loads it
- Processes isolated (can’t access other process’s pages)
- Isolation: each process has separate address space
- Overcommit: can allocate more virtual memory than physical RAM
- Demand paging: pages loaded only when accessed
- Enables swap space to extend RAM
- Built from: Paging, Demand Paging
- Builds into: Swap Space, Thrashing
- Related: TLB, Page Table
- Contrasts with: Physical Memory (virtual vs real)
- Thrashing: too much swapping, system becomes very slow
- OOM killer: Linux kills processes when memory exhausted
- Swap on SSD wears out flash cells