Sobes.tech
Junior — Middle

Explain the working principle of the OOM Killer mechanism in the Linux operating system and its role during memory shortage.

sobes.tech AI

Answer from AI

OOM Killer (Out-Of-Memory Killer) is a mechanism in the Linux kernel that activates during critical memory shortages. When the system exhausts available memory and swap, the kernel attempts to free memory by terminating processes to prevent system hang or crash.

Working principle:

  • The kernel monitors memory usage.
  • When memory is low, the OOM Killer is triggered.
  • The mechanism selects a process to terminate based on various criteria such as process priority, runtime, memory consumption, etc.
  • The selected process is terminated, freeing up memory.

The role of the OOM Killer is to protect the system from complete hang due to memory exhaustion, sacrificing one or more processes to maintain overall system functionality.