Does Ubuntu freeze and become unresponsive because it runs out of memory? There is a solution.

earlyoom terminates processes when RAM and swap are running low to prevent Linux from freezing. Documentation

Installation on Ubuntu/Debian:

sudo apt update
sudo apt install earlyoom
sudo systemctl enable --now earlyoom

Configuration:

sudo nano /etc/default/earlyoom

Example configuration:

EARLYOOM_ARGS="-m 2,1 -s 5,2 -r 60 --avoid ^(rubymine|node|Anno5[.]exe|dota2)$"
  • -m 2,1 — send SIGTERM when available RAM is ≤2%, and SIGKILL when it is ≤1%.
  • -s 5,2 — corresponding free swap thresholds: 5% and 2%. Both RAM and swap conditions must be met at the same time.
  • -r 60 — log memory status once per minute.
  • --avoid — processes that should be avoided when selecting a process to terminate; this is not absolute protection.
  • Lower thresholds mean later intervention.

Apply the changes and verify:

sudo systemctl restart earlyoom
journalctl -u earlyoom -n 15 --no-pager

Залишити коментар

Ваша e-mail адреса не оприлюднюватиметься. Обов’язкові поля позначені *

Цей сайт використовує Akismet для зменшення спаму. Дізнайтеся, як обробляються дані ваших коментарів.