% NOHANG(8) | Linux System Administrator's Manual
nohang - A sophisticated low memory handler
nohang [OPTION]...
nohang is a highly configurable daemon for Linux which can correctly prevent out of memory (OOM) and maintain system responsiveness under low memory conditions.
- Linux (>= 3.14, since MemAvailable appeared in /proc/meminfo)
- Python (>= 3.3)
- Linux (>= 4.20) with CONFIG_PSI=y
- Notification server (most desktop environments use their own implementations).
- libnotify (Arch Linux, Fedora, openSUSE) or libnotify-bin (Debian GNU/Linux, Ubuntu).
- sudo if nohang started with UID=0.
Show this help message and exit.
Show version of installed package and exit.
Consume memory until 40 MiB (MemAvailable + SwapFree) remain free, then terminate the process.
Path to the config file. This should only be used with one of the following options: --monitor, --tasks, --check.
Check and show the configuration and exit. This should only be used with the -c/--config option.
Start monitoring. This should only be used with the -c/--config option.
Show tasks state and exit. This should only be used with the -c/--config option.
Vanilla nohang configuration file.
Configuration file with settings optimized for desktop usage.
File with default nohang.conf values.
File with default nohang-desktop.conf values.
Optional log file that stores entries if separate_log=True.
Logrotate config file controlling rotation in /var/log/nohang/.
- nohang.conf provides vanilla default settings without PSI checking, badness correction, or GUI notifications enabled.
- nohang-desktop.conf provides default settings optimized for desktop usage.
Problems can occur with out-of-tree kernels and modules:
- The ZFS ARC cache is memory-reclaimable, like the Linux buffer cache; however, unlike the buffer cache, it currently does not count to MemAvailable [1]. See also [2] and [3].
- Linux kernels without CONFIG_CGROUP_CPUACCT=y (linux-ck, for example) provide incorrect PSI metrics, see this thread [4].
The program can be configured by editing the config file; the configuration includes the following sections:
- Memory levels to consider an OOM threat
- Response on PSI memory metrics
- Frequency of checking memory availability (and CPU usage)
- Prevention of killing innocent victims
- Modify process badness by matching their names, cmdlines, and UIDs with regular expressions
- The execution of a specific command or sending any signal instead of SIGTERM
- GUI notifications:
- notifications of corrective actions taken
- low memory warnings
- Verbosity
- Misc
Read the parameter descriptions, edit the values, and restart the daemon to apply changes.
Check the config for errors:
$ nohang --check --config /path/to/configThe safest way is to run nohang --memload. This causes memory consumption; the process will exit before OOM occurs. Another method is running tail /dev/zero; this causes fast memory comsumption and OOM at the end. If testing occurs while nohang is running, these processes should be terminated before OOM occurs.
To view the latest entries in the log (for systemd users):
$ sudo journalctl -eu nohang.serviceor
$ sudo journalctl -eu nohang-desktop.serviceYou can also enable separate_log in the config to log to /var/log/nohang/nohang.log.
Sending SIGTERM, SIGINT, SIGQUIT, or SIGHUP signals to nohang causes it to display corrective action stats and exit.
Please direct questions and bug reports to https://github.com/hakavlad/nohang/issues.
Alexey Avramov hakavlad@gmail.com.
https://github.com/hakavlad/nohang
oom-sort(1), psi-top(1), psi2log(1)