Prevent desktop freezes with earlyoom

Install a tiny daemon that kills memory hogs before Linux thrashes into an unresponsive swap storm.

LinuxmonitoringperformancememoryoomMedium risk
Install earlyoom and run sudo systemctl enable --now earlyoom — it kills the biggest memory offender when free RAM and swap drop below a threshold.

01Command

Command
$ sudo systemctl enable --now earlyoom

02What it does

When RAM and swap run out, the kernel spends nearly all its time swapping instead of responding, and even the kernel OOM killer may never get a chance to run. earlyoom watches available memory and SIGTERMs (then SIGKILLs) the process with the highest oom_score while there is still headroom, keeping the system interactive. It is a few hundred kilobytes, needs no cgroup setup, and works on any init system.

03Risk

RiskMedium risk
Requirementsearlyoom package (apt install earlyoom / dnf install earlyoom / pacman -S earlyoom). Works on any distro; no special kernel settings needed.
!Warning: earlyoom will kill a process — by default the largest memory consumer, which may be your unsaved editor if it is the hog. Check its log with journalctl -u earlyoom to see what it killed, and consider --prefer/--avoid flags to steer it toward browsers or away from critical apps.

04Undo

Undo
$ sudo systemctl disable --now earlyoom

05Sources

  • earlyoom - Early OOM Daemon
    GitHub / rfjakob · community · 2026-09-17
    Evidence: README instructs installing the package and running sudo systemctl enable --now earlyoom, and documents defaults like -m 5 (kill at 5% RAM) and --prefer.
  • earlyoom README (raw)
    GitHub / rfjakob · community · 2026-09-17
    Evidence: Shows earlyoom.service and 'sudo systemctl enable --now earlyoom' plus tuning flags -m, --prefer and the low-memory kill logic.

Last verified: 2026-09-19 · Category: System & Settings

06Related solutions