Glossary

Virtual Memory

Virtual memory gives every process its own private range of addresses. The kernel and the CPU map those addresses onto physical RAM, disk-backed files or swap, page by page.

What is virtual memory?

A program never sees physical RAM directly. It sees a large, continuous range of addresses that belongs to it alone, from address zero up to a huge limit (128 TiB of user space on typical 64-bit Linux). The kernel decides which parts of that range are backed by real memory, and the CPU translates each address on every access. Two processes can use the same address for completely different data, and neither can read the other's memory. That isolation is the foundation of process security and stability.

How does the translation work?

Memory is split into pages, usually 4 KiB on x86 and on most Arm64 Linux builds (some Arm distributions use 64 KiB). For each process the kernel keeps page tables that map virtual page numbers to physical frames. The CPU's memory management unit walks those tables, and a cache called the TLB keeps recent translations so most accesses need no walk at all. When a process touches a page that is not mapped yet, a page fault occurs and the kernel fills it: with a zeroed page, a page read from a file, or a page brought back from swap. The hardware side is described on Memory management unit (MMU).

Why are VSZ and RSS so different?

Because reserving address space is not the same as using memory. ps and top show both:

ps -o pid,vsz,rss,comm -C postgres,php-fpm8.3,java --sort=-rss | head
FigureMeaningUse it for
VSZ / VIRTAll virtual address space reserved, used or notAlmost nothing; it is often huge and harmless
RSS / RESPages currently in physical RAMRough memory use, but shared pages count in every process
PSSRSS with shared pages divided among sharersFair per-process totals
SwapPages moved out to swapSpotting memory pressure

A Java process might reserve 40 GB of address space while using 6 GB. Twenty PHP-FPM workers each show 80 MB RSS, but much of it is shared code, so the real total is far less than 1.6 GB. smem -tk or /proc/PID/smaps_rollup give PSS for honest numbers.

What can be behind a virtual page?

  • Anonymous memory: heap and stack, backed by RAM and, under pressure, by swap.
  • File-backed memory: program code, libraries and files opened with mmap. Clean pages can simply be dropped and reread from disk.
  • Shared memory: one set of physical pages mapped into several processes, as databases do for their buffer caches.

Because unused or clean pages can be dropped, the sum of all processes' virtual memory can far exceed physical RAM without trouble. Trouble starts when the pages actually in use exceed RAM: then the system swaps heavily or the OOM killer acts (Out of memory (OOM)).

Is swap the same as virtual memory?

No, though older documentation sometimes uses the terms loosely. Virtual memory is the whole address translation system. Swap is one of its tools: disk space where the kernel can park anonymous pages that have not been used for a while. A server can run with no swap and still use virtual memory for everything. Swap on Linux covers when a swap file helps.

What are huge pages?

Pages of 2 MiB or 1 GiB instead of 4 KiB. With fewer, larger pages, the TLB covers much more memory, which speeds up programs that touch large areas of RAM, such as databases, JVMs and virtual machines. Linux offers transparent huge pages (automatic) and explicit huge pages reserved in advance. Some databases prefer explicit huge pages and ask you to disable the transparent kind; check with cat /sys/kernel/mm/transparent_hugepage/enabled and follow your database's guidance. On large-memory boxes such as M6 with 768 GB DDR4, huge pages can make a measurable difference for VM hosts.

Why should a server admin care?

Reading memory numbers correctly avoids two classic mistakes: panicking over big VIRT figures, and undercounting real use by forgetting shared memory or the page cache. Use free -h for the system view, PSS for per-process totals and the OOM log for proof of real shortage. Linux memory management goes through the tooling on a running Linux box.

Machines With Room for Big Address Spaces

ServerProcessorCores / threadsMemoryStorageNetworkPer monthSmallest order
S5Intel Xeon E-2276G6 / 12128 GB DDR42x 1 TB NVMe2x 10 Gbps$88.72$88.72 (1 month)
S7Intel Xeon E-2288G8 / 16128 GB DDR42x 1 TB NVMe2x 10 Gbps$100.72$100.72 (1 month)
M12x Intel Xeon Gold 5315Y16 / 32512 GB DDR42x 4 TB NVMe2x 25 Gbps$414.70$414.70 (1 month)
M62x Intel Xeon Gold 6258R56 / 112768 GB DDR42x 2 TB NVMe2x 25 Gbps$664.12$664.12 (1 month)

Keep Reading

Memory management unit (MMU)

The CPU hardware that turns virtual addresses into physical ones, enforces page permissions and makes virtual machines and containers possible.

Open

Swap on Linux

What swap is for on a RAM-rich server, how to add a swap file on ext4 or XFS, zram as an alternative and how to tell useful swap from thrashing.

Open

Linux memory management

Virtual memory, pages, overcommit, huge pages, cgroup limits and the OOM killer: how Linux hands out RAM and the knobs worth turning.

Open

Physical memory

The real RAM installed in a machine, how Linux divides it between programs, cache and the kernel, and how to read physical memory figures.

Open

FAQ

Quick Answers

Virtual memory is the private address range each process sees. Physical memory is the actual RAM those addresses are mapped onto.

It counts all reserved address space, including areas never touched. RES or PSS show memory actually in use.

No. Swap is disk space the kernel can use to hold idle pages. Virtual memory is the whole mapping system.

Usually 4 KiB, with optional huge pages of 2 MiB or 1 GiB. Some Arm64 builds use 64 KiB base pages.

Use PSS from smem or /proc/PID/smaps_rollup, which shares out memory used by several processes fairly.