27

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.

  • how much RAM do you have? – Baarn Apr 17 '12 at 7:46
  • @OverTheRainbow - Why not consider Page Snooze - chrome.google.com/webstore/detail/… – PeanutsMonkey Apr 17 '12 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. – OverTheRainbow Apr 17 '12 at 15:51
  • Related: Why do web pages take so much RAM? – galacticninja Jul 21 '19 at 5:44
  • @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. – Tim_Stewart Feb 2 at 19:20
-3

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.

| improve this answer | |
  • 19
    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 '12 at 8:43
  • 5
    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 '15 at 9:25
  • 8
    @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 '15 at 23:23
  • 3
    "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. – Piskvor left the building Apr 3 '17 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 '18 at 11:21
13
  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.

| improve this answer | |
  • 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! – Matthew Apr 6 '14 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 '14 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 '14 at 1:06
  • @DanD., Is this script safe? Will it end up crashing the entire Chrome? – Pacerier Jun 8 '15 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 '15 at 0:15
4

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.

| improve this answer | |
  • 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 – ThorSummoner Oct 4 '19 at 17:50
1

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.

| improve this answer | |
1

Use TabsOutliner extension - it will give you easy way to "shut down" the tabs without actually removing them from your context and current session list. Very useful.

Tabs Outliner Extension

| improve this answer | |
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.

| improve this answer | |
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.

| improve this answer | |
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.

| improve this answer | |

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