Skip to main content
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
lookupMapped (nsFault → LoProcess V…MMU + TLB…Physical …Disk Swap…
ROOTProcess Virtual Addr
1 link
Quick 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:
    1. Isolation & Security: One process cannot read or corrupt another process's physical memory.
    2. Demand Paging: Only actively used pages reside in RAM; cold pages can be swapped to disk.
    3. 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; RSS reflects 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.swappiness low 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.
  • mmap Model Loading: Loading multi-GB LLM weights on demand via virtual memory pages.