35

When leaving several tabs open in Google Chrome for hours/days, I notice that some pages end up using huge amounts of RAM, to the point where the whole OS (XP) becomes unresponsive due to paging. When I'm lucky, I can finally bookmark the list of open URLs, close Chrome, and start again; When I'm not, I simply must kill Chrome and hope I can recover the list of open URLs.

  • Why is that? Memory leaks in plug-ins?
  • Is there a way to configure Chrome so that a single tab/page won't use more than a set amount of RAM?

Thank you.

5
  • how much RAM do you have?
    – Baarn
    Apr 17, 2012 at 7:46
  • @OverTheRainbow - Why not consider Page Snooze - chrome.google.com/webstore/detail/… Apr 17, 2012 at 8:27
  • I have 4GB, which is enough except when some web pages end up grabbing 500MB. Thanks for the links on Page Snooze and Session Buddy. Apr 17, 2012 at 15:51
  • 1
    Related: Why do web pages take so much RAM? Jul 21, 2019 at 5:44
  • 3
    @overtberainbow, consider accepting another answer. As the one you accepted is bad advice if you have a 32bit winXP installation. Adding more ram will do nothing, the OS won't display/use anything past 4GB of ram, even if the motherboard/bios accepts it. Feb 2, 2020 at 19:20

9 Answers 9

-9

I think you should just opt for buying as much RAM as your OS can handle. You should not limit Chrome's RAM usage because it will just ruin your surfing experience on the Web. Assuming that you use your computer for surfing the Internet most of the time, you should let Chrome get all the resources it needs in order to deliver the performance that you want for you to "enjoy" running those tabs at the same time.

I don't think there is a way to limit every individual tab's RAM usage but you can limit Chrome's usage altogether. Look here:

https://stackoverflow.com/questions/192876/set-windows-process-or-user-memory-limit

I would rather not do that, if I were you, if I want smooth web surfing.

8
  • 22
    That's not really a solution when you don't have control over the content of the computer you're using (i.e. work computer)
    – Gnoupi
    Apr 17, 2012 at 8:43
  • 8
    Chrome eats up as much RAM as it gets, so adding more RAM is the same as putting more wood in the fire, it burns more.
    – JDuarteDJ
    Jun 4, 2015 at 9:25
  • 11
    @WikiWitz, You are underestimating how much RAM Chrome eats. I'm having 16 GB physical RAM and it's still not enough.
    – Pacerier
    Jun 8, 2015 at 23:23
  • 4
    "Assuming that you use your computer for surfing the Internet most of the time" - that's a major ass-u-m-ption. Not everything is a Chromebook. Apr 3, 2017 at 15:12
  • 1
    This question does not answer the user's question, makes assumptions, tries to essentially whitewash the question with an ignorant response
    – J Collins
    Dec 12, 2018 at 11:21
17
  1. I wrote a Python 2.5 program which kills chrome's renderers when they use over a set amount of memory. I run this program under watch. (note that it uses the psutil module which isn't included with Python.)

    import sys, os, psutil
    
    if len(sys.argv) == 2:
        try:
            limit = int(sys.argv[1])
        except:
            limit = 200 # default 200MB
    else:
        limit = 200
    
    uid = os.getuid()
    for p in psutil.get_process_list():
        try:
            if (p.name == 'chrome' and any('type=renderer' in part for part in p.cmdline)
               and p.uid == uid):
                m = p.get_memory_info()
                #print p.pid,m, m.rss / 1024 / 1024, m.vms / 1024 / 1024
                if (m.rss / 1024 / 1024) > limit: # kill if rss is greater than limit
                    print 'Killed', p.pid
                    p.kill()
        except psutil.error.NoSuchProcess:
            pass
        except psutil.error.AccessDenied:
            pass
    
  2. I rely on Session Buddy to recover the open tabs when chrome fails to restore them.

6
  • How does Chrome handle it's renderers being killed? What behavior does the tab exhibit after its renderer is killed? Oh, I just saw your Session Buddy comment, so that means that Chrome fails to restore them sometimes, okay. Does this happen often? This is really neat, thanks!
    – Mdev
    Apr 6, 2014 at 21:58
  • 1
    @Human The tabs that used that renderer process that was killed become crashed tabs. But although the script above works nicely with Chrome 12 in later versions it also kills extensions which unlike in Chrome 12 are ran in renderer processes rather than in extension ones.
    – Dan D.
    Apr 7, 2014 at 1:05
  • @Human It is possible to lose the last tabs if you fail to click restore. Also even if you have the Last Tabs file, it is not possible to restore tabs from that file. I attempted to determine the format and extract the URLs from it once long ago. It wasn't successful. And I have more trust in SQLite than in the binary format that Chrome uses to store the current session's tabs which is why SB is better.
    – Dan D.
    Apr 7, 2014 at 1:06
  • @DanD., Is this script safe? Will it end up crashing the entire Chrome?
    – Pacerier
    Jun 8, 2015 at 23:24
  • @Pacerier Yes, except when Chrome is still in its delayed tab loading phase after restarting, it isn't.
    – Dan D.
    Jun 10, 2015 at 0:15
6

The only thing I've seen to date that can do this is to run chrome inside a container and limit the containers ram.

However this has some major caveats,

  • Running chrome is complicated by the dockerize setup and launch sequence

  • for one, Chrome already uses kernel containers to sandbox its threads; so you have to run the container with a kind of root privilege that allows that to work. This can be circumvented, and the linked container model does so. (it does practically everything it needs to)

  • You will almost certainly loose gpu acceleration

  • getting audio to work is complicated, but handled in the linked container model.

  • Whatever else you expect to go wrong when you void your warranty, Chrome violently dislikes being told not to use more ram, and will act up and tantrum accordingly.

But it ultimately does work.

I am more interested in applying these ram limits to Electron Shell apps which don't have prebuilt docker images to rangle them for you.


Off topic but I want to note that Firefox is very well behaved on limited hardware, but I don't consider that a real answer.

1
  • I should update this answer to tell more about how containers are just a cgroup interface, you can use cgroups yourself to accomplish the same Oct 4, 2019 at 17:50
3

Not exactly an answer to this question, but since Chrome 79 you can limit a total amount of memory after which Chrome will start unloading unused tabs, using TotalMemoryLimitMb policy.

To set this policy on Windows:

  1. Go to the following path in Registry Editor (create the trailing keys if missing):
    HKEY_CURRENT_USER\Software\Policies\Google\Chrome
    
  2. Create a new DWORD value called TotalMemoryLimitMb;
  3. Edit the value and enter your limit (minimum 1024). Make sure you enter it as a decimal value.

To set this policy on Mac see these answers. You could also try it on Linux, but apparently it's not supported there.


See my answers here for ways to reduce the average memory usage.

2

It isn't necessarily plugin. Note that webpages are no longer static. Some webpages just have a non-trivial amount of async activity going on. Add on the activity from the plug-ins and you got some unknowns.

The best remedy I have found is to kill the webpage and reload it. AFAIK, there is no way to limit the amount of RAM a webpage uses.

2

Using the TabsOutliner.com extension gives you an easy way to "shut down" the tabs without actually removing them from your context and current session list.

Very useful.

(Credit: I am the original author.)

1
  • Been a fan for years, multiple paid licenses, Google should really just hire you, important work. The core memory issue your tool solves is one of many important features and just the beginning for what your tool empowers people to do. Your only competitor is github.com/cxw42/TabFern, and your full name is written next to their open source license/copyright as their directly/openly attributed inspiration. (I edited superuser.com/review/suggested-edits/1042745 to improve your S.E.O. and give you proper authorship credit.) Mar 5, 2021 at 12:20
1

TabMemFree will automatically suspend inactive tabs. You can determine how long before it suspends inactive tabs, with a minimum of 15 minutes. You can also instruct it to ignored pinned tabs.

Tab Wrangler is another extension to consider that automatically suspends inactive tabs if you’re looking for a little more control. Like TabMemFree, you can determine the length of time before a tab is considered inactive and set it to ignore pinned tabs, but you have the added option to lock additional tabs and to sync your tab settings between different computers.

0

Kill the tab process that's using the large quantity of memory (I notice that anything with Flash tends to use 500MB+). You can just reload the dead tabs later when you want to resume working in them.

0

Limiting RAM in Chrome can be a touchy subject, due to how Chrome handles memory allocation. Say you have 8GB of RAM in your computer - Chrome will attempt to collect more memory as it goes. If you're scrolling a long web page it will keep requesting more allocation until you hit your memory capacity, beyond that and Chrome will simply crash. So if you limit it to something like 500MB or something essentially what you're bound to run into is more frequent freezing when trying to have multiple tabs open. It's also worth noting that a new "tab" is really just a new instance of the application. So having three tabs open is really having three Chromes open.

You must log in to answer this question.

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