When memory runs out: OOM, swap and NUMA

: the kernel in the middle, handing every program its memory. This lesson follows what the kernel does when the memory it promised is not there.
On 28 November 2026 I ran a small Python program on a Linux machine with 16 GB of RAM. It asked the kernel for 4 GB, then 8 GB, then 16 GB. The kernel said yes to all three. That is 28 GB promised on a machine that holds 16 GB. Then I ran another program inside a box limited to 100 MB, and it tried to use 300 MB. It did not get an error message. It was killed, and the only trace was the number 137.
Both are normal. By the end of this lesson you will be able to say what Linux does when a program asks for more memory than exists, when memory truly runs out, and why the same memory read can be slower on a big server.
The history (optional)
On 24 September 2004, Andries Brouwer replied on the Linux kernel mailing list to Thomas Habets. Habets had proposed a setting so that chosen programs would never be killed when memory ran out. Brouwer answered with a story about an aircraft company that flew with less fuel to save money, and threw a passenger out when fuel ran short. His point: killing a process is a poor emergency tool, and arguing about whom to kill never ends. LWN printed the thread on 28 September 2004.
Before you start. In The address book every process carries you saw that asking for memory only writes a promise into a program’s page table, and that a real page of RAM is handed over at the first touch, through a page fault. A program with less RAM than its working set (the pages it uses right now) thrashes, waiting for the disk. The Memory Hierarchy (cache, locality, the memory wall) gave the reason: the disk is far slower than RAM. Running a Container for Real showed the exit code 137 from the outside.