21

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
-2

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.

  • 16
    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
  • in that case it would be good if there was a way to set 'priorities' to selected tabs (like the active tab gets most of the memory) since with limited RAM and with a computer you don't own the user is the one that should adapt (by reducing the number of tabs open) which is counterproductive. – WikiWitz Apr 17 '12 at 14:58
  • 3
    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
  • 5
    @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
  • 2
    "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 Apr 3 '17 at 15:12
12
  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.

  • 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
3

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

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.

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

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

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.

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.