How to make google-chrome or chromium use less memory

32,221

Solution 1

I am using cgroup this way:

sudo cgcreate -a $USER:$USER -t $USER:$USER -g memory:groupChromiumMemLimit
sudo cgset -r memory.limit_in_bytes=$((1024*1024*1024)) groupChromiumMemLimit
cgexec -g memory:groupChromiumMemLimit chromium-browser

The chromium itself may get somewhat slowed sometimes, as it seems to be swapping, but it will not make the whole system hang on swapping other applications, so just chromium/chrome will swap as soon it "reaches 1GB limit".

But... if you look at htop, you will see many chromium processes that sum the resident memory a bit beyond 1GB, I think I need more info on this.

havent tried yet memory.soft_limit_in_bytes to see if it helps in some way, as is suggested in the link provided by https://superuser.com/a/1168435/157532.

but overall, chromium is using much less RAM than it used to, and it is clearly being swapped a lot, so these cgroup commands are working despite of what I can see at htop, so cgroup seems to try to keep chromium using "not much more than 1GB" what is good enough.

Solution 2

There is a plugin you could use to write memory of unused open tabs to swap. It releases that ammount of memory, so CHrome/chromium shows less memory consumption.

Search for Tab-suspender on the webstore of plugins.

https://chrome.google.com/webstore/detail/tab-suspender/fiabciakcmgepblmdkmemdbbkilneeeh

Solution 3

There are a couple of other Chromium options you could use:

  1. Since Chromium 67 you may also want to disable Site Isolation to save another 9-11%, using flag chrome://flags/#site-isolation-trial-opt-out or --disable-site-isolation-trials command line option;
  2. You could explicitly limit the amount of renderer processes using --renderer-process-limit=2 command line option. This will put all of your extensions into a single process and ensure single process is used for all tabs as well. This didn't improve memory usage in my case, but I guess it depends on kind and amount of extensions you use, so it can be useful overall;
  3. Now if you really really want your Chrome-like to use less memory no matter what, you could enable low-end device mode. This will force your browser to think you're using some very poor Android device, so it will be clearing memory cache of inactive tabs and using 16-bit (65 536) colors for images. The option is --enable-low-end-device-mode.

Finally, there is a --single-process option, but it's not officially supported, so it's not guaranteed to work, may still use more than a single process and may cause additional performance or stability issues. The use of more supported options above will give you a better balance between performance and memory usage.

Warning!
Most of these options will reduce the security of your browser! You use them at your own risk.


I was testing these options on Vivaldi 3.3 (Chrome 85) with 5 Super User tabs, 3 other tabs and 4 extensions. Here are the results I've got:

Default:                                            24 processes, ~920 MB
Default - Site Isolation:                           19 processes, ~835 MB,  -9%
Process per Site:                                   19 processes, ~770 MB, -16%
Process per Site - Site Isolation:                  13 processes, ~665 MB, -27%
Process per Site - Site Isolation + Renderer Limit: 10 processes, ~665 MB, -27%

Solution 4

I have the same issue, and I am not alone: Chrome/Chromium eats a lot of memory. Sometimes, this cause the system to freeze (in my case, Linux Mint 17).

solution 1

As a workaround I've started to use this Chrome-Extension: the-great-suspender

solution 2

But there are several other solutions, for example linux cgroup (https://gist.github.com/juanje/9861623)

other solutions

I have attached my other solutions to my first answer to similar question.

Anyway: Chrome is a good (probably best) web-browser, and sites today have high requirements (a lot of JS, canvas, SVG, embed video, web-sockets..). Trying to cut some of functionality - is not a good idea. The only one problem I am trying to solve (at least for me): nobody wants to sit near frozen system.

Share:
32,221

Related videos on Youtube

crysoberil
Author by

crysoberil

Updated on September 18, 2022

Comments

  • crysoberil
    crysoberil over 1 year

    My computer has only 4GB memory, and opening 8-12 random tabs on chrome or chromium often freezes my computer. Currently I'm using google-chrome-stable --process-per-site. This helps to some extent. Is there any way to run chrome or chromium in a single process? Could anyone give me some tips on how to control chrome's excessive memory usage?

    • Admin
      Admin over 8 years
      Why do you feel Chrome is using more memory then it needs? Modern browsers would be extremely slow if they only used a single process. What makes you think Chrome would use less memory if it was only a single process?
    • Admin
      Admin over 8 years
      I think one time I checked, I found IE was much much better in terms of memory footprint. IE was a joke for a while like V6-V9 or something until around v10 or v11. They say the current version isn't too bad. Take a look at it. Also look at Opera which was historically not too memory hungry.. Though I must say I just checked IE and in one of its instances it used 102MB.. which seems like a lot.. but anyhow, see if you find IE uses less than chrome. You could try very small browsers like "off by one" but they may not show all pages correctly.
    • Admin
      Admin over 8 years
      Even though RAM is expensive, when you're low on RAM, more RAM is a good investment, pays off straight away!
    • Admin
      Admin over 8 years
      Chrome by it's nature uses a lot of memory. The best way to save memory would be use another browser.
    • Admin
      Admin almost 8 years
      As you do not specify, on linux you can have swap as compressed ram using zram, the package is zram-config. Helps on avoiding long freezes.
    • Admin
      Admin over 7 years
      Try qupzilla, a lightweight browser.
    • Admin
      Admin about 7 years
      "Why do you feel app X is using more memory than it needs?" Because it's easy, in general: just hog all the RAM you can allocate, whether you need it or not, that's an order of magnitude easier than doing anything about it. (If running Chrome was all I did on the box, I wouldn't care that opening a blank tab "needs" hundreds of MBs. Alas, I sometimes need other processes...)
    • Admin
      Admin almost 5 years
      Possible duplicate of Limiting use of RAM in Chrome?
  • Aquarius Power
    Aquarius Power almost 8 years
  • Aquarius Power
    Aquarius Power almost 8 years
    but your suggestion is much more cool, changed to it, thx!
  • jcoffland
    jcoffland over 5 years
    top shows memory usage in bytes, MB, GB or TB. These are powers of 1000 not 1024. That's probably why you're seeing it go slightly above your target.
  • Dan Dascalescu
    Dan Dascalescu about 4 years
    Also, will this persist reboots? How does it compare with this solution that writes to /sys/fs/cgroup/memory/myGroup/memory.limit_in_bytes?
  • Aquarius Power
    Aquarius Power about 4 years
    @DanDascalescu btw, I think this doesnt work very well now... chromium spawns more than 15 independent threads and that limit would apply to each thread (and not a limit to them all like a group limit). I will try to find a way to create a limit that SUMs each thread and limit them all together (and not isolated like it seems to be right now).
  • EvgenKo423
    EvgenKo423 about 3 years
    So the --single-process option works for you? Which browser version do you have?
  • leogama
    leogama about 3 years
    @EvgenKo423 Yes, it works. But the browser doesn't use literally a "single process", it actually uses 4 processes (the main one plus 3 zygote subprocesses). The option gets rid of utility, renderer and gpu-process types of independent processes. I'm using Chromium version 89.0 on Linux (Ubuntu 20.04, Snapstore app).
  • user99999991
    user99999991 almost 3 years
    Have not seen much improvement at all over the past year. A blank gmail tab, according to Chrome's Task Manager, even in the background and not the focused tab takes a whopping 250MB. Even opening a Microsoft Office 360 tab doesn't take that much! Though it does clock in at a disgusting 180MB anyway
  • EvgenKo423
    EvgenKo423 almost 3 years
    @user99999991 Well, it depends. Chrome 89 was only released in March this year and for Edge you must be on Windows 10 2005+. It also greatly depends on which sites you visit. It's only 20 MB per GMail-like tab, but several tabs will add up more significantly.
  • user99999991
    user99999991 almost 3 years
    this was observed with 1 gmail tab and using chrome's built in manager which lets you see the resources used by each individual tab. the gmail tab, even with no emails on screen and nothing in the inbox list, clocks in at 250MB for me.
  • Thunder_Ruler
    Thunder_Ruler over 2 years
    For anyone looking for The Great Suspender, it has been discontinued.