Part 1 of 7 · 1 min read
Why this page comes seventh
In this module you will
- Explain what swap space is, and why anonymous pages need it to be evicted.
- Explain overcommit, and read the settings that control it.
- Say what the OOM killer does, how it picks a victim, and what a program sees when it is chosen.
- Limit the memory of a process with
ulimit -vor a cgroup, and predict the result. - Tell a failed
mallocfrom a killed process, and say how to plan for each.
Level 6 ended with thrashing: the point where the frames are too few for the pages in use. This page continues past that point. It asks what the kernel can promise, what it does when it cannot keep the promise, and how a program can protect itself. It also pays two debts of earlier pages: the swap space of Level 6 page 7, and the thread stacks of page 3, whose address space is reserved and mostly unused. Page 8 then puts the tools together. The sources are OSTEP chapter 22, OSC chapter 10 and TLPI chapter 6, with the kernel documentation for the settings. The test programs were compiled with gcc -O2 -Wall -Wextra and run on a Linux machine with 8 GiB of memory and no swap space.
About this example About this example
Real: The facts, definitions and algorithms on this page come from the books named in the text. No program on this page was timed.
Scripted: The worked traces use small numbers chosen so they can be followed by hand.
Not real: The page simplifies real systems. Actual kernels add more cases, limits and tuning than a short page can show.