Limiting use of RAM in Chrome?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Magical Minnie Puzzles
--
Chapters
00:00 Limiting Use Of Ram In Chrome?
00:33 Answer 1 Score 17
01:05 Answer 2 Score 6
02:08 Answer 3 Score 3
02:51 Answer 4 Score 2
03:19 Answer 5 Score 2
03:33 Thank you
--
Full question
https://superuser.com/questions/413349/l...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#googlechrome
#avk47
ANSWER 1
Score 17
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
I rely on Session Buddy to recover the open tabs when chrome fails to restore them.
ANSWER 2
Score 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.
ANSWER 3
Score 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:
- Go to the following path in Registry Editor (create the trailing keys if missing):
HKEY_CURRENT_USER\Software\Policies\Google\Chrome
- Create a new DWORD value called
TotalMemoryLimitMb
; - 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.
ANSWER 4
Score 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.
ANSWER 5
Score 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.)