LinuxCommandLibrary

choom

Forcefully kill a process if memory low

TLDR

Display the OOM-killer score of the process with a specific ID

$ choom [[-p|--pid]] [pid]
copy

Change the adjust OOM-killer score of a specific process
$ choom [[-p|--pid]] [pid] [[-n|--adjust]] [-1000..+1000]
copy

Run a command with a specific adjust OOM-killer score
$ choom [[-n|--adjust]] [-1000..+1000] [command] [argument1 argument2 ...]
copy

SYNOPSIS

choom [-p PID] [-n ADJ | -r | -l] [--]

PARAMETERS

-h, --help
    Display help and exit.

-V, --version
    Show version information.

-p, --pid PID
    Target process ID (default: current shell).

-n, --adjustment ADJ
    Set OOM adjustment (-1000 to 1000).

-r, --reset
    Reset adjustment to default (0).

-l, --list
    List current OOM adjustment.

DESCRIPTION

choom displays or modifies the Out-Of-Memory (OOM) score adjustment for a process or thread. The Linux kernel's OOM killer activates during severe memory pressure, selecting victims based on oom_score derived from memory usage, niceness, and the adjustable oom_score_adj value (-1000 to 1000) stored in /proc/PID/oom_score_adj. Negative values protect processes (e.g., -1000 for immunity), while positive values prioritize termination.

This tool helps tune process resilience: protect critical services like databases, or mark resource hogs for quicker culling. It supports single PIDs (tasks), defaults to the current shell, and requires appropriate privileges. Mutually exclusive modes prevent invalid combinations. Ideal for sysadmins managing memory-intensive workloads on servers or desktops.

CAVEATS

Requires CAP_SYS_RESOURCE or root for non-owned processes. No effect on PID 1 (init). Modes (-n/-r/-l) are mutually exclusive. Cgroup v2 uses unified hierarchies.

EXAMPLES

choom 1234
List PID 1234 adjustment.
choom -n -900 $$
Protect current shell.
choom -p 1234 -r
Reset PID 1234.

PRIVILEGES

Owner can always read/write own /proc/PID/oom_score_adj; others need elevated caps.

HISTORY

Introduced in procps-ng 3.3.10 (2014-10) to simplify /proc/oom_score_adj access, replacing ad-hoc echo commands.

SEE ALSO

ps(1), top(1), kill(1), proc(5)

Copied to clipboard