Saturday, February 8, 2014

OOM (Out of Memory) Killer in Linux


If a memory hog is left unchecked in the system, then an Out of Memory (OOM) error will eventually result. A kernel component or an application tries to allocate memory & the OS can neither allocate this memory because RAM is full nor can swap out some RAM pages because even swap space is full. This is called OOM error.

For kernel allocations, its the availability of Low memory that matters. If there is no more low memory, its is considered OOM error. It doesn't matter how much high memory is still available.

Linux handles OOM error by invoking OOM killer. The OOM killer selects a random process & kills it to free up some RAM. I will not delve into the rules OOM killer uses to select the process because I don't think this way of dealing with OOM error does any good to the system. By letting OOM killer kill some random process, it only makes debugging the resulting functional problems more difficult. For this reason, embedded systems typically deal with OOM error by reseting the system hoping that a fresh boot solves the memory hog. Before the system reset is invoked, it is typical to dump information from various memory tools so that the cause of OOM error can be troubleshooted offline & fixed in future releases/patches. In my upcoming posts, I will cover the tools useful for troubleshooting memory hog.

No comments:

UA-48797665-1