How set the "oom_score_adj" when(before) run target program?

5,425

oom_score_adj is inherited on fork, so you can set its initial value for new children by setting the desired value on the parent process.

Thus if you’re starting the target from a shell script,

echo 1000 > /proc/$$/oom_score_adj

will change the shell’s value to 1000, and any process subsequently forked by the shell will start with oom_score_adj set to 1000.

Share:
5,425

Related videos on Youtube

illiterate
Author by

illiterate

Updated on September 18, 2022

Comments

  • illiterate
    illiterate almost 2 years

    Directly set by echo 1000 >/proc/<pid>/oom_score_adj is unreliable because target program is already running , in this case maybe target program caused OOM before echo 1000 >/proc/<pid>/oom_score_adj