Sobes.tech
Middle

What is OOM Killer and can it be controlled?

sobes.tech AI

Answer from AI

OOM Killer (Out-Of-Memory Killer) is a mechanism in the Linux kernel that activates when the system runs out of RAM and swap space to continue operating. In such situations, the OOM Killer selects and terminates one or more processes to free up memory and prevent the entire system from crashing.

Controlling the OOM Killer can be done in several ways:

  • Adjusting process priorities via oom_score_adj — you can set a value from -1000 (process protected from killing) to +1000 (process more likely to be killed).
  • Kernel parameter tuning — for example, through /proc/sys/vm/overcommit_memory and /proc/sys/vm/overcommit_ratio, you can influence memory allocation behavior.
  • Using cgroups — limit memory consumption for groups of processes to prevent the OOM Killer from triggering at the system level.

Example of changing a process's priority:

# Get the process PID
pid=1234
# Set oom_score_adj to -500 (reduce the likelihood of killing)
echo -500 > /proc/$pid/oom_score_adj