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?
- 331
- 1
- 2
- 4
-
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 07 '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 07 '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 07 '15 at 13:10
-
3Chrome by it's nature uses a lot of memory. The best way to save memory would be use another browser. – qasdfdsaq Aug 07 '15 at 14:12
-
1As 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. – Aquarius Power May 11 '16 at 06:43
-
Try qupzilla, a lightweight browser. – Serhat Cevikel Jan 17 '17 at 23:47
-
1"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...) – Piskvor left the building Apr 03 '17 at 15:10
-
Possible duplicate of [Limiting use of RAM in Chrome?](https://superuser.com/questions/413349/limiting-use-of-ram-in-chrome) – galacticninja Jul 21 '19 at 05:43
6 Answers
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.
- 785
- 12
- 19
-
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 02 '18 at 10:50
-
Also, will this persist reboots? How does it compare with [this solution](https://unix.stackexchange.com/a/136479/29324) that writes to `/sys/fs/cgroup/memory/myGroup/memory.limit_in_bytes`? – Dan Dascalescu 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). – Aquarius Power Mar 10 '20 at 21:48
There are a couple of other Chromium options you could use:
Since Chromium 67 you may also want to disable Site Isolation to save another 9-11%, using flag
chrome://flags/#site-isolation-trial-opt-outor--disable-site-isolation-trialscommand line option;Warning!
Since about July 2022 this option breaks all of Cloudflare CAPTCHAs/challenges!!
This appears to be a browser bug. Either that or Cloudflare is intentionally using Site Isolation / Spectre to detect browsers...You could explicitly limit the amount of renderer processes using
--renderer-process-limit=2command 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;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%
- 195
- 1
- 1
- 10
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
- 39
- 3
-
there is "the great suspender" too https://chrome.google.com/webstore/detail/the-great-suspender/klbibkeccnjlkjkiokjodocebajanakg?hl=en – Aquarius Power May 11 '16 at 06:39
-
-
Update: This functionality has been built-in to Chrome since at least 2021. – Jim Grisham Sep 05 '22 at 07:58
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.
- 208
- 1
- 9
-
For anyone looking for The Great Suspender, it has been discontinued. – Thunder_Ruler Aug 27 '21 at 23:38
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
- 563
- 4
- 7
-
So the `--single-process` option works for you? Which browser version do you have? – EvgenKo423 Mar 21 '21 at 11:17
-
2@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 '21 at 01:59
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 OSes 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.
I was testing memory usage by different Chromium versions on Windows 7 SP1 with 7 modern heavy sites and 3 extensions. Here are the results I've got:
Vivaldi 3.3 / Vivaldi 3.7 / Vivaldi 5.6 /
Chrome 85 Chrome 89 Chrome 108
By mode (total):
Default: 18 processes 21 processes 20 processes
~1855 MB ~1715 MB, -7% ~1930 MB, +4%
Default - Site Isolation: 16 processes 18 processes 17 processes
~1780 MB ~1705 MB, -4% ~1930 MB, +8%
Process per Site: 16 processes 18 processes 17 processes
~1705 MB ~1620 MB, -5% ~1850 MB, +8%
Process per Site - Site Isolation: 12 processes 14 processes 13 processes
~1555 MB ~1530 MB, -1% ~1690 MB, +8%
Process per Site - Site Isolation 9 processes 11 processes 11 processes
+ Renderer Limit: ~1550 MB ~1530 MB, -1% ~1685 MB, +8%
By type (private set @ default mode):
Browser process (Vivaldi-specific?): ~130 MB ~160 MB, +23% ~160 MB, +23%
GPU process: ~120 MB ~115 MB, -4% ~190 MB, +58%
Renderer processes: ~1345 MB ~1170 MB, -13% ~1045 MB, -22%
GMail (mentioned in comments): ~195 MB ~175 MB, -10% ~110 MB, -43%
Overall Chromium 89+ is more dynamic in using renderer processes, so it's hard to tell an exact consumption. These results were recorded after a minute since all the sites had been fully loaded.
Indeed, in Chromium 89 total memory usage decreased by ~7% (~140 MB) @ default mode, with almost no decrease in least-isolated modes. However, with later updates Chromium effectively lost all of its advances showing increase by ~8% across most tested modes (at least on Windows 7), even with further optimizations of renderer processes!...
- 195
- 1
- 1
- 10
-
1Have 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 – user99999991 May 12 '21 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 '21 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. – user99999991 May 14 '21 at 01:40