Created
March 11, 2018 23:50
-
-
Save jayeye/9d2962c7ab59b1782f8a274f050a9ee7 to your computer and use it in GitHub Desktop.
Run chrome in its own memory-limited cgroup
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
Ugly hack to run chrome in a memory-limited cgroup so it does not kill your workstation | |
when it tries to consume all available memory. | |
Put this in /usr/local/bin/cchrome, add that to whatever menu system you are using. | |
You can verify it worked by running: | |
grep memory `ps ax | grep chrome | grep -v grep | awk '{printf "/proc/%s/cgroup\n", $1}'` | |
This has only been tested on kubuntu desktop. Obviously, if you have not enabled | |
passwordless-sudo for yourself, create and chmod the cgroup directory from some | |
startup script! |
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
#!/bin/sh | |
sudo mkdir -p /sys/fs/cgroup/memory/chrome | |
sudo chmod -R a=rwX /sys/fs/cgroup/memory/chrome | |
echo 8G > /sys/fs/cgroup/memory/chrome/memory.limit_in_bytes | |
exec cgexec -g memory:chrome google-chrome |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 4 works without sudo and tee?
UPD: Nevermind, chmod. :)