Autokill Chrome when RAM is low
Is there a way to make Chrome never use all of the RAM available? My autistic daughter often opens up too many tabs, and there's this AtoZ Animal web site she likes where even a single tab can quickly consume all of the available RAM (many gigabytes just for one tab).
My current fix for the problem is this simple bash script that just kills Chrome when RAM gets low:
#!/bin/bash
while true; do
free -mt | grep Total
FreeTotal=$(free -mt | grep Total | awk '{print $4}')
if [[ "$FreeTotal" -le 150 ]]; then
echo LOW RAM KILLING CHROME
killall -TERM chrome
fi
sleep 5
done
It checks every 5 seconds, and if total free RAM+swap is under 150 megs it kills Chrome. Crude but effective.
Is there a better solution, like something that simply tells Chrome to "sleep" or reload tabs when RAM is low?
Thanks!