Virtual Memory
Virtual memory gives each process a private address space and maps its addresses to physical memory or other backing storage. The operating system and processor cooperate to provide isolation, controlled sharing, and demand-loaded pages.
itOperating systems | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Intro
Virtual memory is the system that separates the addresses used by a program from the physical locations that hold its code and data. Each process works inside a private virtual address space. The processor's memory management unit, or MMU, translates each virtual address through page tables maintained by the operating system.
This indirection solves several problems at once. A process can use a continuous range of addresses even when its physical page frames are scattered. Separate page tables isolate processes from one another. Permissions can make a region readable, writable, executable, or inaccessible. Multiple processes can also map the same file or shared-memory object without giving up their private address spaces.
Virtual memory does not mean “RAM plus disk.” Swap is one possible backing store for anonymous pages, but address translation, isolation, permissions, file mappings, and demand allocation still matter on a system with no swap device.
The translation path
Memory is managed in fixed-size units called pages. Physical memory is divided into page frames. A virtual address contains a virtual page number and an offset within that page. The offset survives translation; the virtual page number selects a page-table entry that identifies a physical page frame and carries status and permission bits.
Page tables are hierarchical because a flat table for a large address space would consume memory for ranges that a process never uses. The upper address bits select an entry at the first level, the next bits select the next level, and so on. A leaf entry names the physical frame. Some architectures also let a higher-level entry map a large page, which shortens the walk and covers more memory with one translation.
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://docs.kernel.org/admin-guide/mm/concepts.html
Supports
- Virtual addresses, physical pages, page tables, demand paging, protection, and sharing
- Anonymous memory, page cache, reclaim, compaction, swap, and OOM concepts
- https://docs.kernel.org/mm/page_tables.html
Supports
- Hierarchical page tables, page frames, large mappings, MMU, TLB, dirty and permission bits
- Expected faults, copy-on-write, invalid accesses, SIGSEGV, and Linux page-table evolution
- Atlas and Intel 80386 virtual-memory milestones
- https://learn.microsoft.com/en-us/windows/win32/memory/virtual-address-space
Supports
- Private process address spaces and page-table translation
- https://learn.microsoft.com/en-us/windows/win32/memory/virtual-address-space-and-physical-storage
Supports
- Working sets, page organization, paging-file backing, and transparent movement of pages
- https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/managing-memory-sections
Supports
- Demand allocation, first-access faults, file-backed loading, and copy-on-write views
- https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/file-backed-and-page-file-backed-sections
Supports
- File-backed, page-file-backed, shared, and copy-on-write section behavior
- https://www.man7.org/linux/man-pages/man2/mmap.2.html
Supports
- Linux anonymous and file mappings, shared and private mappings, protections, and fixed-address hazards
- https://www.man7.org/linux/man-pages/man5/proc_pid_smaps.5.html
Supports
- RSS, PSS, clean and dirty private or shared pages, anonymous memory, swap, page sizes, and flags
- https://www.man7.org/linux/man-pages/man5/proc_pid_statm.5.html
Supports
- Virtual size, resident and shared counts, counter accuracy, and the detailed smaps alternative
- https://www.man7.org/linux/man-pages/man5/proc_pid_stat.5.html
Supports
- Process virtual-memory size and resident-set definitions
- https://docs.kernel.org/mm/overcommit-accounting.html
Supports
- Linux overcommit modes, commit limits, mapping costs, and allocation guarantees
- https://docs.kernel.org/admin-guide/sysctl/vm.html
Supports
- OOM selection, overcommit controls, swap readahead, and memory-policy behavior
- https://docs.kernel.org/admin-guide/mm/transhuge.html
Supports
- Transparent huge-page purpose, fallback, promotion, demotion, and splitting
- https://docs.kernel.org/admin-guide/mm/multigen_lru.html
Supports
- Working-set reclaim, refault protection, thrashing prevention, and OOM trade-offs
- https://docs.kernel.org/admin-guide/cgroup-v2.html
Supports
- Memory-control-group limits, reclaim, pressure, and OOM events
- https://docs.kernel.org/admin-guide/mm/zswap.html
Supports
- Compressed swap cache, swap input and output trade-offs, and backing-device eviction
- https://www.cs.manchester.ac.uk/about/history-and-heritage/
Supports
- 1962 Atlas operation and first use of virtual memory
- https://www.vm.ibm.com/history/timeline.html
Supports
- CP-40 in 1964, CP-67 in 1967, and VM/370 in 1972
- https://multicians.org/history.html
Supports
- June 1967 Multics paging and segmentation development milestone
- Multics three-level virtual-memory backing model
- https://web.mit.edu/Saltzer/www/publications/f7y/f7y.html
Supports
- Multics paging and segmentation design and project history
- https://www.ibm.com/history/system-370
Supports
- August 1972 System/370 virtual-memory support and practical effect
- https://www.ibm.com/docs/en/zos-basic-skills?topic=storage-brief-history-virtual-64-bit-addressability
Supports
- System/370 virtual storage and 1983 System/370-XA 31-bit addressability
- https://timeline.intel.com/1985/raising-the-bar-with-the-386
Supports
- Intel 80386 introduction on October 17, 1985
- https://ir.amd.com/financial-information/sec-filings/content/0001193125-04-037179/d10k.htm
Supports
- April 2003 AMD Opteron introduction and AMD64 extension of x86 to 64-bit computing
- https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/40332.pdf
Supports
- AMD64 long mode, expanded virtual addressing, and large-memory motivation
- https://kernel.org/doc/ols/2011/ols2011-masters.pdf
Supports
- Transparent Huge Pages included in Linux 2.6.38 in March 2011
- https://lkml.iu.edu/hypermail/linux/kernel/1709.0/01229.html
Supports
- Linux 4.14 as the first kernel able to enable five-level x86 paging in 2017
- https://github.com/sindresorhus/awesome
Supports
- Discovery path to the Awesome eBPF list
- https://github.com/qmonnet/awesome-ebpf
Supports
- Ecosystem discovery for BCC and bpftrace
- https://github.com/awesome-foss/awesome-sysadmin
Supports
- Ecosystem discovery for Sysdig as a Linux troubleshooting tool
- https://github.com/iovisor/bcc
Supports
- BCC memory, process, page-cache, reclaim, compaction, OOM, and allocation tools
- https://bpftrace.org/one-liners
Supports
- bpftrace page-fault counting and stack profiling examples
- https://docs.sysdig.com/en/docs/sysdig-monitor/using-monitor/metrics/metrics-library/sysdig-legacy-format/system/
Supports
- Process virtual memory, resident memory, swap, and major or minor page-fault metrics
