Suppose a backend service has 40 MiB of code and read-only data, reserves 512 MiB for its heap, and creates several thread stacks.
The operating system does not need to load all of that memory into RAM immediately. In practice, the service may use only a small portion of its code, heap, and stacks.
Instead, the OS can make those virtual memory regions available and load individual pages only when they are first accessed. This is called demand paging.
Demand paging loads a page into physical memory only when the process actually needs it.
The first access may trigger a page fault. The kernel then loads or creates the page, updates the page table, and retries the instruction. Future accesses can use the page directly while it remains in memory.
This chapter separates virtual-region validity from physical residency, follows first-access faults for anonymous, executable, and stack pages, and examines first-touch latency, fault cost, replacement, and Linux observation.