Created
January 11, 2018 19:18
-
-
Save ar45/3c977311c9b8f32948eeca25a7ba2198 to your computer and use it in GitHub Desktop.
Limit Google Chrome Memory Hungry Eating up 32GB of ram
This file contains hidden or 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
[Unit] | |
Description=Chrome browsers cgroup | |
After=multi-user.target | |
[Service] | |
ExecStart=/bin/bash -x -c '[ -d /sys/fs/cgroup/memory/user.slice/chrome ] || /bin/mkdir /sys/fs/cgroup/memory/user.slice/chrome; chmod 766 /sys/fs/cgroup/memory/user.slice/chrome/tasks; echo "Satrting"; CHROME_MEMORY_LIMIT_IN_BYTES=${CHROME_MEMORY_LIMIT_IN_BYTES:-5368709120}; echo "${CHROME_MEMORY_LIMIT_IN_BYTES}" >/sys/fs/cgroup/memory/user.slice/chrome/memory.limit_in_bytes; echo "Setting CHROME_MEMORY_LIMIT_IN_BYTES=${CHROME_MEMORY_LIMIT_IN_BYTES}";' | |
;ExecStart=/bin/mkdir /sys/fs/cgroup/memory/user.slice/chrome | |
;ExecStop=/bin/rm /sys/fs/cgroup/memory/user.slice/chrome | |
EnvironmentFile=-/etc/environment | |
Type=oneshot | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install systemd unit to initialize the cgroup
Add the following line to
/usr/bin/google-chrome
or wherever your chrome is installed at the beginning of the shell script.To move existing chrome processes to the new cgroup, do
Set environment variable