Reference

Virtual Memory

Virtual memory is an abstraction that gives each process its own private address space, which the OS maps to physical RAM (and sometimes disk) in fixed-size pages. It isolates processes and lets the system run programs that need more memory than is physically installed.

APIs & internalsGeneral

Virtual Memory

Also known as: virtual memory explained, paging memory, virtual memory

Virtual memory is an abstraction that gives each process its own private address space, which the OS maps to physical RAM (and sometimes disk) in fixed-size pages. It isolates processes and lets the system run programs that need more memory than is physically installed.

  • The MMU translates per-process virtual addresses to physical RAM in ~4 KB pages.
  • A page fault loads or allocates a page on first access or after reclaim.
  • RAM (virtual memory) and file storage are separate budgets, not interchangeable.

How virtual memory works

Each process sees a continuous range of virtual addresses. The CPU's memory management unit (MMU) translates those virtual addresses to physical RAM addresses using per-process page tables, typically in 4 KB pages. This means two apps can both use address 0x1000 without colliding, because each maps to a different physical page.

When a process accesses a page that is not currently in RAM, the MMU raises a page fault and the kernel loads or allocates the page. Pages can be backed by a file (code, mapped files) or be anonymous (heap, stack). Under memory pressure the OS reclaims pages: clean file-backed pages are simply dropped and reloaded later, while dirty anonymous pages must be written to swap space first (or, on iOS/Android, the app may be asked to free memory or be killed instead).

Why it matters for storage math

Virtual memory is why "memory" (RAM the OS manages with paging) and "storage" (the flash/SSD that holds your files) are separate budgets, even though paging can spill RAM contents to disk. A phone with 8 GB RAM and 256 GB storage uses virtual memory to juggle far more allocated address space than 8 GB across many apps; it does not turn storage into usable photo space.

On iOS, there is no traditional user swap for apps, so the system relies on virtual memory plus memory-mapped files and aggressive termination of background apps under pressure. On Android, zRAM provides compressed swap. Either way, freeing storage does not free RAM and vice versa, which is why a storage cleaner reclaims disk space, not memory.

Related terms

Keep reading the reference.

Act on it

Guides and tools for this topic.