How Linux Decides Which Process to Kill When Memory Runs Out
Linux uses an 'overcommit' memory strategy that allows processes to request more memory than physically available, deferring actual allocation until pages are accessed. When physical memory and swap are fully exhausted, the kernel's Out-Of-Memory (OOM) killer activates and selects a process to terminate based on a badness score derived from memory usage and a per-process adjustment value called oom_score_adj. Processes like sshd are pre-configured with an oom_score_adj of -1000, making them effectively exempt from being killed so administrators can still access the system after an OOM event. In containerized environments such as Kubernetes, a separate cgroup memory controller enforces per-container memory limits and triggers its own localized OOM kill when a container exceeds its allocated ceiling. Understanding how the OOM killer scores and selects victims can help engineers configure their systems to protect critical processes and reduce costly production incidents.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in