How do I determine and configure the likelihood that a process will be killed in a out-of-memory situation?
Issue
- How to adjust a process score calculations for Out-of-memory situations
Environment
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 5
Resolution
It is possible to adjust the oom-score for each process on the system. In the '/proc' file system, there are 2 files for each system enlisted task that provide control over the likelihood that a proccess should be terminated. These files are:
-
/proc/[pid]/oom_adj— Used to adjust the "OOM score", which determines the likelihood of a process being killed in an out-of-memory situation. A higher OOM score means a higher likelihood that the process will be killed byoomkill. Valid values are -17 to 15; note that an OOM score of -17 means[pid]will never be killed.
To specify an OOM score, simplyechothe score to/proc/[pid]/oom_adj. For example, to set an OOM score of 15 to[pid]1111, run:echo 15 > /proc/1111/oom_adj
Note that the OOM score is inherited from parent processes to child processes duringfork()operations. -
/proc/[pid]/oom_score— Displays the current OOM score for a given process. Usecatto display the current OOM score for[pid]. For example, to view the current OOM score for[pid]1111, run:cat /proc/1111/oom_score