CSOS & ConcurrencyDiagramIntermediate
Virtual Memory
KO: 가상 메모리·EN: Virtual Memory·JA: 仮想メモリ
An OS memory abstraction giving each process its own isolated, contiguous virtual address space dynamically mapped to physical RAM and swap via the MMU
Table of Contents
Structure Diagram
Virtual Memory Address Translation & Swap MappingTap a node
ROOTProcess Virtual Addr
1 linkQuick Answer
What is Virtual Memory?
An OS memory abstraction giving each process its own isolated, contiguous virtual address space dynamically mapped to physical RAM and swap via the MMU. It is a core concept in OS & Concurrency within CS.
Core Principles
Virtual Memory is an OS + hardware (MMU) abstraction giving every process its own private, contiguous address space, decoupled from physical RAM layout.
- Three Key Benefits:
- Isolation & Security: One process cannot read or corrupt another process's physical memory.
- Demand Paging: Only actively used pages reside in RAM; cold pages can be swapped to disk.
- Shared Memory & Copy-on-Write (CoW): Shared libraries and
fork()children share identical physical frames until a write triggers a copy.
Practical Takeaways
- Read RSS, not VSZ: Virtual size (
VSZ) includes unallocated reservations and mapped files;RSSreflects actual physical RAM usage that triggers the OOM killer. - Prevent Swap Thrashing: Heavy major page faults to disk degrade latency by orders of magnitude—databases and latency-sensitive services tune
vm.swappinesslow or disable swap. - Leverage
mmap: Mapping files into virtual memory avoids user/kernel copies for high-speed engines like LMDB and Kafka.
Notable Examples
- Redis BGSAVE via CoW
fork(): Snapshotting gigabytes of RAM while copying only mutated pages. mmapModel Loading: Loading multi-GB LLM weights on demand via virtual memory pages.