4 ms·
It's 2026 and I still can't configure the OOM killer to kill firefox before anything else.
by rwmj 5mo ago
It's 2026 and I still can't configure the OOM killer to kill firefox before anything else.
- dvh 5mo agoThis. It's always browser running amok. I configured win+k shortcut key to: killall -9 chrome
- SoftTalker 5mo agoI always wanted it to target java processes, as they were always the culprit. These days it's python, VSCode, and antigravity.
- bellowsgulch 5mo agoI looked into this, and actually, it seems like maybe you can? https://man7.org/linux/man-pages/man5/proc_pid_oom_score_adj.5.html https://man7.org/linux/man-pages/man5/proc_pid_oom_score_adj... So, in actuality, I think your assertion just taught us all something, because despite knowing that the OOM killer and that the Magic SysRq key[1] exists, I didn't know you could configure this as an input! [1]: https://en.wikipedia.org/wiki/Magic_SysRq_key https://en.wikipedia.org/wiki/Magic_SysRq_key
- rwmj 5mo agoI'm aware of it, but it's awkward to use in practice. You have to track down all the FF processes, each time you run it, and adjust all their scores.
- loeg 5mo agoMaybe firefox could self-adjust, as a policy?
- rwmj 5mo agoYes this would be nice. Or maybe the OOM system would have two other files, /sys/oom/kill_first and /sys/oom/kill_never which would solve the problem more directly for the majority of cases. I should really send a patch rather than complaining ...
- pavon 5mo agoIt looks like it does, which depending on your goal is either helpful or part of the problem. By default processes should inherit their parent's oom_score_adj. If I exit out of firefox completely, then start it up (with no saved tabs), this is the behavior I see: $ firefox-esr& PID=$!; choom -p $PID -n 42 [1] 105360 pid 105360's OOM score adjust value changed from 0 to 42 $ for p in $(ps --ppid $PID -opid --no-headers $PID); do printf "%3d" $(</proc/$p/oom_score_adj); ps -opid,comm --no-headers $p; done 0 105360 firefox-esr 0 105425 Socket Process 167 105451 Privileged Cont 0 105456 RDD Process 100 105495 WebExtensions 0 105524 Utility Process 233 105534 Web Content 233 105542 Web Content 233 105549 Web Content See how each firefox process has a different oom_score_adj with Web Content being more likely to be killed than other processes (233), and none of them have the value that the process was started with (42). This is Firefox 140.11 ESR running on Debian 13.
- loeg 5mo agoNice!
- nick__m 5mo agoYou could launch it as a systemd user target with OOMScoreAdjust=500 in the service section; weird and unconventional but wrapped in .desktop file it doesn't appear to be unwieldy.
- jitl 5mo agosounds like a job for a program
- bellowsgulch 5mo agoAh. Yes, that is awkward. Well, nonetheless, you taught me a new feature. Thanks!
- deleted 5mo ago[deleted]
- IsTom 5mo agoIt's not a panacea, but in my case setting browser.tabs.unloadOnLowMemory in about:config helped a bunch.
- yjftsjthsd-h 5mo agoMaybe not in kernel, but running the earlyoom daemon will let you do exactly that in userspace.
- 3r7j6qzi9jvnve 5mo agoIf it helps, I run ff in systemd-run with memory limits set -- that's usually enough to avoid the problem in the first place (ff does freeze when loading google spreadsheets or whatever heavy UI, so I also have a script to adjust /sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/ff-*.scope/memory.max and memory.high at runtime... I should publish my $bindir someday) systemd-run --user --scope --unit=ff-$$.scope \ -p MemoryMax=4G -p MemoryHigh=3G \ -p MemorySwapMax=0 \ firejail firefox "$@"
- ars 5mo agoInstall oomd or earlyoom. https://github.com/facebookincubator/oomd/ https://github.com/facebookincubator/oomd/ https://github.com/rfjakob/earlyoom https://github.com/rfjakob/earlyoom
- silon42 5mo agoOr to kill anything at all in this lifetime.
- jolmg 5mo agoYou can use `earlyoom --prefer firefox --avoid xlock`.
- po1nt 5mo agoIt would be nice to have a signal as a warning to process to reduce it's memory footprint or else OOM will kill it.
- masklinn 5mo agoIt’s possible via cgroups, kinda. cgroups v1 has a pretty nice API but it requires root. V2 does not require root but it’s a lot coarser and not as simple or reliable: https://unix.stackexchange.com/questions/753929/receive-a-memory-pressure-event-with-cgroups-v2-when-no-memory-limit-is-set https://unix.stackexchange.com/questions/753929/receive-a-me...
- Joker_vD 5mo agoYou still need some way to make the kernel to send those signals to the processes of your choosing. If the kernel decides to send SIGLOWMEM to xlock instead of firefox, the xlock will get killed because it really doesn't have any memory it can give up.
- masklinn 5mo agoSIGLOWMEM, if it existed, would have no reason to default to anything other than IGN. It would also logically be sent to “every” process on the machine, with the subsystem probably having a heuristic to skip processes which were already signaled and have not had significant memory increases since. The goal of an early warning is to cooperatively release memory (and maybe abort memory intensive computations), the kernel already kills processes “at random”, it does not need a second way to do that.
- NekkoDroid 5mo agohttps://systemd.io/MEMORY_PRESSURE/ https://systemd.io/MEMORY_PRESSURE/