11

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.

4
  • Have you looked into limits.conf or ulimit?
    – DopeGhoti
    Commented Jan 24, 2018 at 16:45
  • That's a wonderful idea! Too bad ulimit is unsupported for Windows!
    – jpaugh
    Commented Jan 24, 2018 at 18:16
  • I have few (React dev, plugin, Vimium, Addblock, few google plugins) So I don't excpect those to eat like 4GB of RAM
    – Jan Kaifer
    Commented May 22, 2018 at 20:53
  • My Solution was buy more memory, now have 32GB , no issues anymore
    – deFreitas
    Commented Jun 19, 2020 at 15:13

3 Answers 3

8

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.

1
  • 2
    I have the same problem with Firefox, even though it works fine on another RAM-constrained system, with far less available to it. I think browser developers have decided they should use to all RAM available, on any system.
    – jpaugh
    Commented Jan 24, 2018 at 18:19
4

I believe that you can use the ulimit utility. The -d option: ulimit(3) man page

You can lower your soft limit even without root access to the server.

1

Another way to improve Chrome's behavior is to simply configure the JavaScript heap limits. Add this to the command line when starting Chrome:

--js-flags="--max_old_space_size=80 --max_semi_space_size=80"

This tells the JavaScript GC to limit memory usage to under 160M Of course you can change the numbers for your specific situation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .