liveBook · Manning

Memory page

As explained in Latency

A page is a fixed-size block of virtual memory that the operating system maps independently to physical memory or storage.

A memory page is a fixed-size chunk of virtual memory that the CPU and operating system map independently to physical memory or storage. Pages are typically 4 KiB, though 2 MiB and other sizes are possible. This granularity lets an application see a contiguous virtual address space even when its physical pages are scattered. section 7.4.3 section 7.4.4

A page’s physical backing and access cost can change during execution:

  • The page table records how a virtual page maps to a physical page; adjacent virtual pages need not occupy adjacent physical locations. section 7.4.4
  • With demand paging, the operating system can leave a virtual page unmapped until its first access causes a page fault and physical allocation. section 7.4.4
  • Under memory pressure, the operating system can move a page to disk and later read it back, changing access from memory speed to disk speed. section 7.4.3 section 7.4.4
Figure 7.4 A process’s virtual memory address space consists of sections that serve different purposes. The text, data, and BSS sections are initialized at program startup, whereas the heap, memory-mapped region, and stack sections change dynamically at runtime (denoted with dotted lines).

Use the process address-space diagram to locate pages within text, data, BSS, heap, memory-mapped, and stack regions, and distinguish startup-fixed from dynamically changing regions. section 7.4.3

Figure 7.5 A page table is a data structure the CPU uses to translate virtual memory addresses to physical addresses. A page in virtual memory does not always have a counterpart in physical memory. Instead, the OS can store a page on the disk, for example, and lazily move it to physical memory when it’s accessed.

Use the page-table diagram to trace virtual addresses to physical memory or disk and visualize lazy movement into physical memory. section 7.4.4

How Latency covers it

How deep it goes
Defines page granularity, page tables, demand paging, faults, and swapping, but defers application controls to a later treatment.
Examples
Uses 4 KiB and 2 MiB pages, noncontiguous address mappings, process regions, and disk-backed pages as concrete examples.
What it assumes
Assumes application memory and processes while establishing virtual memory, physical memory, page tables, and page faults.
What you can do after
Evaluate memory-access latency by relating virtual-page access to physical allocation, page faults, and disk residency.
How it connects
Connects virtual memory with physical memory, page tables, demand paging, page faults, swapping, and process memory regions.

Also explained in

Compare how 2 books explain memory page →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Latency. The section links point to the parts of the book it draws on.