Skip to content

Instantly share code, notes, and snippets.

@arpat
Created October 25, 2018 10:26
Show Gist options
  • Save arpat/18407271a34e79d3aefb6ea85fcebeeb to your computer and use it in GitHub Desktop.
Save arpat/18407271a34e79d3aefb6ea85fcebeeb to your computer and use it in GitHub Desktop.
Finds chrome renderer processes and ups their OOM kill score on Linux
#!/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