User Tools

Site Tools


ubuntu:out_of_memory_oom:kill_specific_processes_first_when_out_of_memory

Ubuntu - Out of Memory (OOM) - Kill specific processes first when out of memory

todo

How to kill specific processes started by 'x' or 'y' before anything else gets killed.

The OOM-killer is buried deep inside the kernel and has a very obscure algorithm.


oom_score_adj

/proc/[pid] contains oom_score_adj

Adjust the score using the /proc/$(pidof mysqld)/oom_score_adj file to give the kernel some clue.

man proc 

describes the old oom_adj.

Ubuntu supports the following using Upstart and the oom score configuration option.

oom score

Linux has an “Out of Memory” killer facility.

Normally the OOM killer regards all processes equally, this stanza advises the kernel to treat this job differently.

The “adjustment” value provided to this stanza may be an integer value from -999 (very unlikely to be killed by the OOM killer) up to 1000 (very likely to be killed by the OOM killer).

Example:

# This application is a "resource hog".
oom score 1000
 
expect daemon
respawn
exec /usr/bin/leaky-app
ubuntu/out_of_memory_oom/kill_specific_processes_first_when_out_of_memory.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki