19

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?

8
  • 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?
    – Ramhound
    Aug 7 '15 at 11:11
  • 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.
    – barlop
    Aug 7 '15 at 13:04
  • Even though RAM is expensive, when you're low on RAM, more RAM is a good investment, pays off straight away!
    – barlop
    Aug 7 '15 at 13:10
  • 3
    Chrome by it's nature uses a lot of memory. The best way to save memory would be use another browser.
    – qasdfdsaq
    Aug 7 '15 at 14:12
  • 1
    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. May 11 '16 at 6:43
6

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.

3
  • 1
    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.
    – jcoffland
    Dec 2 '18 at 10:50
  • Also, will this persist reboots? How does it compare with this solution that writes to /sys/fs/cgroup/memory/myGroup/memory.limit_in_bytes? Mar 10 '20 at 12:18
  • 1
    @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). Mar 10 '20 at 21:48
4

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

2
2

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.

1
  • For anyone looking for The Great Suspender, it has been discontinued. Aug 27 at 23:38
1

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 --disable-site-isolation-trials command line option or the following flag: chrome://flags/#site-isolation-trial-opt-out;
  2. You could explicitly limit the amount of renderer processes using --renderer-process-limit=2 command line option. It will put all of your extensions into a single process and ensure single process is used for all tabs as well. It didn't improve memory usage in my case, but I guess it depends on the 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. It 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%
0

As an extreme example, I'm using Chromium just for Gmail (in app mode) with some Chrome extensions for Gmail. To reduce the memory footprint, I've set the --single-process mode, which makes sense in cases like this.

I don't use Chromium for anything else, but if it isn't your case you would like to change the User Data Directory for the app mode window, so that it and the regular browser windows run on separated processes with only the app window in single process mode. These are the relevant lines of my Gmail.desktop file:

Exec=/usr/bin/chromium-browser --single-process --class=gmail --user-data-dir=.config/gmail --app=https://mail.google.com/mail
StartupWMClass=gmail
2
  • So the --single-process option works for you? Which browser version do you have?
    – EvgenKo423
    Mar 21 at 11:17
  • 1
    @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).
    – leogama
    Mar 24 at 1:59
0

Also if you have auto-update disabled, now may be the most appropriate time to finally update your browser. In 2020 - early 2021 Microsoft and Google were working on optimization of Chromium memory usage and since Chromium 89 they became available to everyone:

In Chrome M89, we’re seeing significant memory savings on Windows – up to 22% in the browser process, 8% in the renderer, and 3% in the GPU. Even more than that, we’ve improved browser responsiveness by up to 9%. [...]

In addition to improving how we allocate memory, Chrome is now smarter about using (and discarding) memory. Chrome now reclaims up to 100MiB per tab, which is more than 20% on some popular sites, by discarding memory that the foreground tab is not actively using, such as big images you’ve scrolled off screen.

Note that unlike Edge's, Chromium's solution is built-in and will work on all OSs it can run on.

Or you may even switch to another browser, like Vivaldi. It's based on Chromium, has lazy tab loading, easy unloading of background tabs, ad blocker and lots of other useful features built-in.

3
  • 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 May 12 at 14:24
  • @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.
    – EvgenKo423
    May 12 at 15:27
  • 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. May 14 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.