Prevent desktop freezes with earlyoom
Install a tiny daemon that kills memory hogs before Linux thrashes into an unresponsive swap storm.
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 earlyoom02What 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
!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 earlyoom05Sources
- earlyoom - Early OOM DaemonEvidence: 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)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