-
Notifications
You must be signed in to change notification settings - Fork 189
Description
Problem
The current -n / --notify option in earlyoom only sends a D-Bus notification after a process has already been SIGTERM’d or SIGKILL’d.
On desktop systems this is too late — users have no chance to react (close tabs, save work, kill the real culprit themselves) before the automated killer kicks in.
This has been discussed in #54 but issue was closed probably due to earlyoom not supporting notification at that time. Since earlyoom has notification now, this becomes a viable/possible alternative.
Proposed solution
Add an optional early warning notification that fires noticeably before the kill thresholds are reached.
New flags (both optional, preserve 100 % backward compatibility):
| Flag | Meaning | Suggested default |
|---|---|---|
-w MULT, --warn-mult=MULT |
Warning threshold = kill threshold × MULT (in %) | none (disabled) |
--warn-backoff=SEC |
Minimum seconds between repeated warnings | 300 |
Example usage
# Normal kill thresholds
earlyoom -m 10,5 -s 80,50
# Add warning 25 % earlier than the kill threshold + backoff
earlyoom -m 10,5 -s 80,50 -w 125 --warn-backoff 300→ Memory warning at 12.5 % available (instead of 10 %), swap warning at ≈ 62.5 % used, etc.
Implementation impact
- Uses the exact same memavail/swaptotal calculations earlyoom already does every poll cycle
- Hooks into the existing main loop
- No extra polling, no new threads, no new syscalls
- Uses the exact same notification code path as the existing
-n(just a different summary/body, e.g. “Warning: Low memory – consider closing applications”)
This would turn earlyoom into a friendly heads-up system.
Happy to provide a draft PR if you like the idea.
Thanks for maintaining the best userspace OOM killer out there!