NOTE
Memory Allocation and Reclamation
Virtual mappings, physical-page allocation, user-space allocators, reclaim, swap, and OOM.
This is a historical learning note and may contain outdated or incomplete understanding.
Memory allocation spans layers. Applications request virtual memory from user-space allocators/runtime libraries, which obtain mappings/pages from the kernel; the kernel manages physical pages and page tables.
Not every allocation immediately consumes a fresh physical page because mappings can be lazy and pages can be shared/cached. Under pressure, Linux can reclaim file-backed cache, reclaimable kernel memory, and—when configured—swap anonymous pages.
If reclaim cannot satisfy demand inside the effective memory domain, the OOM mechanism may terminate processes.