Low Orbit Flux Logo 2 F

Linux OOM Killer - Out of Memory

The OOM Killer ( Out of Memory Killler ) is part of the Linux kernel. It kills processes to free up memory when the system runs out of memory.

You can check for this with the following:

grep -i kill /var/log/messages*

Messages like this are a good indication that a process was killed by the OOM killer:

host kernel: Out of Memory: Killed process 5645 (server1).

Protect Processes from OOM Killer

For a given process you can set oom_adj to a value between -17 and +15.

Protect process 5645 from being killed:

echo -17 > /proc/5645/oom_adj

Stress Testing

Use memory with stress:

sudo apt install stress

stress -m 1 --vm-bytes 4G --vm-keep

Use up a G of memory with Python:

import numpy
result = [numpy.random.bytes(1024*1024) for x in xrange(1024)]
print len(result)