Created
October 25, 2018 10:26
-
-
Save arpat/18407271a34e79d3aefb6ea85fcebeeb to your computer and use it in GitHub Desktop.
Finds chrome renderer processes and ups their OOM kill score on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# finds chrome renderer processes and ups their OOM kill score on Linux | |
# | |
while read Line | |
do | |
while read -r MemUsed Pid | |
do | |
CmdLine=$(cat /proc/${Pid}/cmdline) | |
echo -n "PROCESS $(echo ${CmdLine}| awk '{ print $1 }')" | |
echo -ne " pid ${Pid} \tmem ${MemUsed} " | |
Renderer=false | |
if grep -q "type=renderer" <(echo ${CmdLine}); then Renderer=true; fi | |
if [ ${Renderer} = true ]; then | |
echo " renderer OOM score up" | |
echo 1000 > /proc/${Pid}/oom_score_adj | |
else | |
echo " leaving be" | |
fi | |
done < <(echo $Line) | |
done < <(ps -C chrome --no-headers -o pmem -o pid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment