GitHub - phiresky/linux-oom-psi-ask: An small standalone interactive userspace OOM handler for Linux, inspired by how macOS does it. · GitHub
/" data-turbo-transient="true" />
Skip to content
Search/
Sign in<br>Sign upAppearance settings
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
phiresky
linux-oom-psi-ask
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Latest commit
History<br>3 Commits<br>3 Commits
Folders and files<br>NameNameLast commit message<br>Last commit date<br>src
src
.gitignore
.gitignore
Cargo.lock
Cargo.lock
Cargo.toml
Cargo.toml
README.md
README.md
hogs.sh
hogs.sh
install-caps.sh
install-caps.sh
install.sh
install.sh
psi-ask.service
psi-ask.service
run.sh
run.sh
screenshot1.png
screenshot1.png
View all files
Repository files navigation
psi-ask
An small standalone interactive userspace OOM handler for Linux, inspired by how macOS does it.
Instead of deciding to kill a program automatically, it pauses the top<br>candidates and asks how to handle it early enough.
The dialog shows a pressure/memory chart and the biggest memory<br>consumers. Each row has Terminate and<br>Force kill ; "Do nothing" or Escape resumes everything, and a countdown<br>auto-dismisses (once pressure has actually dropped). Firefox's<br>anonymous processes are automatically resolved to their site.
How it works
Arms a kernel PSI trigger on /proc/pressure/memory and sleeps in<br>poll() - zero CPU while idle. Debounces once.<br>--cgroup additionally watches cgroup2 memory.pressure files; a cgroup<br>event lists only that cgroup's processes.
On pressure it SIGSTOPs the top offenders (excluding its own ancestor chain),<br>shows the dialog, and SIGCONTs everything on every exit path.
The binary memory locks itself, sets oom_score_adj = -1000 and nice -20. This is done with setcap so the GUI does not have to run as root.
You will lose around 14MB of system memory since that is locked into this process (+30MB that is likely shared with other processes)
Usage
./install.sh # installs to ~/.local/bin + a systemd user service<br># (setcap, MemoryMin=, no swap, starts with the session)
For a foreground run instead: ./install-caps.sh once, then ./run.sh.
Options
--kind some|full PSI line to trigger on [some]<br>--stall-ms N stall threshold within window [500]<br>--window-s N trigger window, multiple of 2 [2]<br>--cooldown-s N quiet period after each prompt [30]<br>--top N candidates to list [10]<br>--answer-timeout-s N dialog timeout, 0 = wait forever [60]<br>--chart-min N minutes of history in the chart [3]<br>--cgroup PATH also watch this cgroup (repeatable)<br>--no-pause don't SIGSTOP top offenders while asking<br>--window normal movable window instead of overlay
some fires when any task stalls on memory; full only when all do.<br>Defaults are much earlier than systemd-oomd's because a human needs time to<br>answer.
Low Effort Warning
Compared to some of my other projects this is a low-effort project, with the goal of "works for me". The code is made with AI help. It's pretty hard to test this kind of thing because real memory pressure is hard to emulate, so I don't know if it works for all situations. It only supports Wayland right now.
Pressure stall information is pretty guaranteed to be the right trigger because it simply checks how much CPU usage is being spent waiting for memory pages to be moved in and out of RAM. But it might be set too sensitive in the default.
The pausing of processes is not guaranteed to make the system responsive because the thrashing can theoretically come from any selection of processes, not just the highest memory consumers.
Prior art
systemd-oomd: automatic cgroup killer using PSI. You will want this enabled regardless
psi-notify: unprivileged PSI notifier
kernel PSI docs
macOS's out-of-application-memory dialog — the pause-then-ask UX
About<br>An small standalone interactive userspace OOM handler for Linux, inspired by how macOS does it.<br>Resources<br>Readme<br>Activity<br>Stars<br>0 stars<br>Watchers<br>0 watching<br>Forks<br>0 forks<br>Report repository
Releases
Packages
Contributors
Languages
You can’t perform that action at this time.