Virtual memory
Virtual memory gives each process its own private address space, which the operating system maps onto physical memory behind the scenes.
Virtual memory is the system that gives every process its own view of memory, called an address space. The addresses a program uses are virtual, and the processor translates each one to a real place in physical memory. The kernel keeps the translation in page tables, which map memory in fixed-size pages. Pages that a process has not touched need not exist in physical memory at all.
Virtual memory keeps processes apart, since one process cannot even name another's memory. It lets the kernel share pages between processes, such as copies of the same library. It lets programs use more memory than is free, by moving unused pages to swap or loading them only when needed. Translation has a cost, which the processor hides with a cache of recent translations.
Virtual machines add a second layer of translation. The guest's kernel maps its processes' addresses to what it thinks is physical memory, and the hypervisor maps that to the host's real memory. Processors translate both layers in hardware, so the cost stays small. Because memory is mapped page by page, hosts can overcommit memory and share identical pages between sandboxes.
Related terms