Address space

On this page 7

An address space is the complete range of memory addresses that a process, a kernel or a hardware device can refer to, together with the rules that determine which addresses are valid and what they point to. In operating systems, the term usually means the virtual address space of a process: a private, contiguous-looking view of memory that the kernel and the memory management unit translate into scattered physical page frames.

Address spaces are the foundation of memory management because they provide isolation between programs, allow each program to be linked as if it owned the machine, and let the operating system overcommit, share and swap memory without the program noticing. Most memory protection features, from segmentation faults to address space layout randomization, are defined in terms of address spaces.

How a virtual address space is mapped to physical memory

A process never touches physical RAM directly. Every load or store uses a virtual address, which the memory management unit (MMU) translates through the process’s page tables into a physical address. Recently used translations are cached in the translation lookaside buffer, so most accesses avoid a full table walk.

The address space is divided into fixed-size pages, typically 4 KiB, with optional huge pages of 2 MiB or 1 GiB on x86-64. Each page table entry records whether a page is present, writable, executable and accessible from user mode. When a process switches, the kernel loads a different page table root, such as the CR3 register on x86, and the whole view of memory changes at once.

Valid regions are only a small part of the possible range. Unused addresses are simply not mapped, and touching them causes a fault that the kernel reports as a segmentation fault or access violation. Mapped pages that are not yet in RAM cause a page fault that the kernel resolves through demand paging.

Address space sizes on common architectures

The size of an address space is set by the width of virtual addresses that the processor supports, not by installed RAM. The following table shows typical limits; exact values depend on the processor generation and the operating system configuration.

ArchitectureVirtual address bitsTotal rangeTypical user portion
32-bit x86324 GiB2 GiB or 3 GiB
x86-64, 4-level paging48256 TiB128 TiB
x86-64, 5-level paging57128 PiB64 PiB
ARMv8-A, 48-bit48256 TiBUp to 256 TiB per translation table
ARMv8.2-A, 52-bit524 PiBUp to 4 PiB per translation table
Typical virtual address space limits

On 64-bit systems, addresses must be canonical: the unused upper bits must copy the highest implemented bit. This splits the space into a lower half for user programs and an upper half usually reserved for the kernel, with a large unusable gap between them.

The typical layout of a process address space

A process address space is organized into regions with distinct permissions, each backed by a file, by anonymous memory or by nothing until first use. The kernel tracks these regions in structures such as Linux virtual memory areas or Windows virtual address descriptors.

RegionContentsPermissionsBacking
Text segmentProgram machine codeRead and executeExecutable file
Data and BSSInitialized and zeroed globalsRead and writeFile, then anonymous
HeapDynamic allocationsRead and writeAnonymous memory
Memory-mapped areaShared libraries and mapped filesVaries by mappingFiles or anonymous memory
StackCall frames and local variablesRead and write, no executeAnonymous, grows on demand
Kernel spaceKernel code and dataSupervisor mode onlyShared across processes
Regions in a typical user address space

Modern systems apply address space layout randomization (ASLR), placing the stack, heap, libraries and often the executable at random offsets on each run. ASLR does not prevent memory bugs, but it makes exploits much less reliable because attackers cannot predict where useful code sits.

Several neighboring terms are often confused with address space. The distinction that matters most is that an address space is a range plus a mapping, while the other terms describe single addresses, physical storage or the amount actually used.

ConceptWhat it describesRelation to address space
Physical address spaceAddresses on the memory bus, including device registersTarget of virtual translation
Virtual addressOne location as seen by a programA single point inside the space
Page tableData structure holding translationsDefines the mapping of the space
Resident set sizePages currently held in RAMUsually far smaller than the mapped space
Working setPages actively used in a time windowSubset of the resident pages
How address space differs from related memory terms

Devices can have their own views as well. An IOMMU gives a device a separate I/O virtual address space, which limits direct memory access to approved buffers. Processor architectures also distinguish memory addresses from port-mapped I/O addresses on x86.

Sharing, protection and the limits of isolation

Separate address spaces do not mean separate copies of everything. The kernel can map the same physical pages into several address spaces, which is how shared libraries, shared memory segments and copy-on-write after fork save RAM. Each mapping still carries its own permissions.

Isolation has practical limits that engineers should keep in mind:

  • A large virtual size is not a memory leak, because reserved but untouched regions consume no RAM.
  • 32-bit processes exhaust their space long before a 64-bit machine runs out of RAM, often through fragmentation of large allocations.
  • Context switches between address spaces cost time because translation caches must be flushed or tagged with identifiers such as PCID or ASID.
  • Side-channel attacks such as Meltdown showed that hardware may leak data across address space boundaries, which led to kernel page table isolation.

Stripped to the essentials

An address space is the set of memory addresses a program is allowed to use. Each program gets its own private numbering, as if it had the whole computer’s memory to itself.

Think of an apartment building where every tenant has a private floor plan numbered from one upward. The building manager, here the operating system, knows which real room each number leads to. Tenants cannot walk into each other’s rooms, and the manager can rearrange the real rooms without changing anyone’s floor plan.

Where it is applied

A team running a scientific simulation on a workstation with 64 GiB of RAM finds that the old 32-bit build crashes when it tries to allocate a 1.5 GiB array, even though plenty of RAM is free. The cause is the 2 GiB user address space of a 32-bit process on Windows: after libraries and earlier allocations, no single free gap is large enough.

Rebuilding the program as a 64-bit application gives it a user address space of 128 TiB on x86-64. The same allocation now succeeds immediately, and the operating system maps physical pages only as the simulation touches them. The fix required no extra hardware, only a larger address space.