An interactive talk about a practical use of the Linux OOM Killer.
Places and times: Polycloud (2024)
Talkers: Théo Tchilinguirian
I gave this ~20mn talk at Polytech Montpellier, during the Polycloud 2024.
It’s more like a hands-on demonstration of the Linux OOM (Out-Of-Memory) Killer, that is, the mechanism that protects a Linux system against memory overflow.
In Linux, a running program is called a process. The Linux Kernel allocates a vast range of virtual memory to each running process, to keep track of their state, and map their virtual memory to physical RAM efficiently.
The Kernel does not limit processes in how much virtual memory they can use. However, if the total virtual memory of every process exceeds the total physical memory available, the OOM mechanism built into the kernel will wake up to handle the issue.
For this demonstration, I made a program whose only purpose was to fill its virtual memory. However, sometimes programs have bugs that cause memory leaks, which can be an unintentional cause of memory overflow.
Here is what could be observed by running the program:
As you can see, the OOM killer only kills processes as a last resort, and will first use a fascinating memory-rearrangement mechanism. This is quite understandable, as ending working processes should be the very last resort. This mechanism should be well understood by Kubernetes users, as the orchestrator and its Cloud platforms’ derivates make good use of this Kernel mechanism to restart containers and execute alerting procedures in monitoring strategies.
One practical yet peculiar use we can derive from the OOM Killer could be to rearrange unused memory in SWAP.
This mechanism is completely different to CPU throttling, which occurs when the CPU is overused, and merely slows down all processes without causing their death. A simple automatic workflow to manage CPU throttling would simply be to allocate more resources, such as virtual CPUs to a machine, or nodes to a shared resource pool. These strategies are known as “vertical scaling” and “horizontal scaling”, respectively.
It was very fun doing this talk at the Polycloud. This event is hosted each year at the Polytech, where I am currently studying computer science.
This was one of the “free talks” in the evening, and one of my first talks. Thanks to my professors, classmates and professionals from the field for attending my talk!
It was packed with fun, the audience was great and loved the little demonstrations I did in TTY (/dev/random
video and audio pipe) during memory allocation.
And thank you for reading!