# Long Article 106: Memory Management — Advanced: Deep Dive into Copy-on-Write, Swapping, and NUMA Optimization
“When physical memory is insufficient, how does the OS handle it gracefully? This article covers CoW, Swapping, and NUMA optimization.”
Introduction
Three advanced features for memory pressure:
CoW: Share pages on fork, copy only on write
Swapping: Move inactive pages to disk
NUMA Awareness: Prefer local node allocation
Chapter 1: Copy-on-Write
CoW avoids copying all pages on fork. Pages are shared read-only, copied only when written to. Fork speed improves 10-100x with 50%+ memory savings.
Chapter 2: Swapping
When memory is low, kswapd selects inactive pages via LRU and writes them to swap. Page-in happens on access via page fault.
Chapter 3: NUMA
First-touch allocation by default. Interleaved and binding modes available. Automatic NUMA balancing optimizes locality.
Comments