Linux – Chrome eats all RAM and freezes system

arch linuxchromelinuxram

How to prevent chrome to take more than for example 4GB of ram. From time to time he decides to take something like 7GB (with 8GB RAM total) and makes my computer unusable.

Do you have any help.

PS: I even didn't have more than 10 tabs opened.
Edit: maybe I did … something like 15. Anyway I want chrome to freeze or shutdown not to freeze the whole system.

Best Answer

I believe you would want to use something like cgroups to limit resource usage for a individual process.

So you might want to do something like this except with

cgcreate -g memory,cpu:chromegroup cgset -r memory.limit_in_bytes=2048 chromegroup

to create chromegroup and restrict the memory usage for the group to 2048 bytes

cgclassify -g memory,cpu:chromegroup $(pidof chrome)

to move the current chrome processes into the group and restrict their memory usage to the set limit

or just launch chrome within the group like

cgexec -g memory,cpu:chromegroup chrome

However, it's pretty insane that chrome is using that much memory in the first place. Try purging reinstalling / recompiling first to see if that doesn't fix the issue, because it really should not be using that much memory to begin with, and this solution is only a band-aid over the real problem.

Related Question