Browsers eating RAM
flotato.com
flotato.com
This post is unfortunately nonsense, because it's making a fundamental measurement error: not including renderer processes for Safari, and only measuring the browser process (which should be expected to be roughly O(1) memory in the number of tabs).
To the author's credit, they _are trying_ to include child processes - I'm not sure why, but `psrecord` seems to not (in local testing) include child processes for Safari even when the "--include-children" flag is passed. I guess it does for Chrome, for whatever reason.
I'm somewhat disappointed that the author, or half the comments on the post, didn't question these _wildly_ different results though...
What happens instead is that I hit a wall of slowness, forcing me to press the power button and lose all my other work. It's not very gradual, I think due to the nature of the problem, so the browser needs to avoid getting into the situation. It's like UI latency follows a hyperbolic curve, running right up to infinity all of a sudden as the RAM runs out.
I seem to remember that being a pretty common condition back in the 90's. Things would get slow, sure, but not completely and utterly hosed.
When this happened to me recently (unattended Firefox process used up all RAM) the machine was simply never able to recover, even after killing the offending process (thereby making 30GB or so of RAM available) and waiting a half an hour.
[0]https://bugs.launchpad.net/ubuntu/+source/linux/+bug/159356
Now, not so much. Dev machines rarely run out of RAM anyway.
Isn't that what Firefox's "a tab may be slowing down your computer" (or equivalent) is doing? However it does not seem to trigger reliably. Good thing for me i disable JavaScript most times!
> I hit a wall of slowness, forcing me to press the power button and lose all my other work
So that's two parallel problems. First is browser is eating too much RAM. Second is OS starts writing to swap instead of triggering OOM killer, rendering the whole system unusable rather quickly. I personally systematically disable swap on laptops/desktops (but keep it on server).
Ideally, client-side scripting in the browser wouldn't be a thing at all (we'd have established, reproducible, secure software distribution mechanisms like guix's introduction channels). In a better world, a browser would for every page disable Javascript/WASM by default, but have a convenient menu (alla Noscript) to choose between different security/performance profiles: webapp for unlimited resources/permissions, simple for basic JS for minor interactions (like LibreJS does), etc..
In our world, the websites we consume decide what resources they're gonna eat, and how much network resources they're gonna load, leading to unexpected CPU/RAM/network usage (inducing €€€€ bills for cell phone data).
Reality: the task manager will not open because there is not enough RAM. Simply moving the mouse pointer can become impossible.
Attempting to close a window goes like this: estimate the mouse movement needed, carefully move the mouse, then come back in 15 minutes to see if the pointer has moved and if it is in the correct location. If it has moved but not as desired, make another attempt. If it hasn't moved, come back in an hour... then try several hours, or maybe the next day. If somehow the mouse is in the correct location, click the button very slowly. Maybe hold it for minutes or hours?
If I visit a specific web site with a memory abusive app, the browser is supposed to protect me. It's the same as any security hole. Malicious web sites aren't supposed to crash my computer.
Yes, I'm still blaming the browser. It's the browser's job to provide protection here. It's a security matter. No matter what my browsing habits may be, letting the computer lock up is not at all OK.
We shouldn't be one bad web site away from swap lock-up.
There is no possible computer upgrade that will fix the issue. There will always be a more-terrible web site waiting to consume all resources.
> I open lots of tabs, in lots of browser windows, on lots of virtual desktops, but so what if I do?
Hehe, the expected outcome of this behavior on an 8 GiB machine with default settings is a slow computer. You can blame the browser and spend your time frustrated if you want to, or you can choose to avoid asking the computer to use 20 GiB and then complain when it swaps, by requesting less memory and/or disabling virtual memory. It’s not that fair to go on and on about some vague abstract idea of malicious web sites and blaming the browser for not protecting you, if you are choosing to open lots of windows, browsers, desktops, tabs, and web sites.
> It’s the browser’s job to provide protection here.
If you study the browser design, and if you compare today’s browsers to those of 5 or 10 years ago, you will find that all the browser devs are actually bending over backwards trying to help you. They’re not perfect, but all of today’s browsers are pretty amazing in how well they handle low resources - but - the browser is just an application that does what it’s asked to do. If you use a web app that consumes 1GiB, the browser tries to accommodate your request. How is it supposed to know you want it to cut off the app instead of do what you asked? What if the app asks for more memory in the middle of what you’re doing, do you want it to lose your work??
The OS is the software locking up your computer, not the browser. Everything you’re talking about can and does happen with regular applications. Even if you got your wish of a browser that protected you from yourself, it wouldn’t solve the problem that landing in swap locks up the machine.
> There is no possible computer upgrade that will fix the issue.
I disagree completely. I never have the problem you’re talking about, and I use dozens and dozens of tabs all day long every day with multiple browsers. $100 in RAM right now could double or triple your capacity, if you don’t want to disable virtual memory nor change your browsing habits.
Yeah there is no solution to fixing the theoretical problem that some software somewhere can ask for more resources than you have. That’s not the issue you brought up though. In practice, the issues you’ve raised about browsing are quite easily fixable.
"100$ in RAM" - maybe learn what its like to live on most of the planet instead of your tiny walled garden.
There is a way to limit this, and also to provide feedback to the user about what is going on such that the system never swaps or freezes. Instead we get lazy intellectual excuses from the likes of such as yourself.
would be a nice operating system feature
You can get most of Safari processes using plain ps as they share the same command:
ps x -o rss,command | grep Safari
There will be a few system threads (for example used for video rendering) that you will have to tie back to one of the processes using launchctl.
Fun fact: activity monitor actually does it through undocumented private APIs as documented here: https://apple.stackexchange.com/questions/327290/how-process...
Hope it saves someone half a day!
Given that Chrome is busy trying to subsume the web and the OS (it has bluetooth now, and usb, and serial ports, and over a thousand chrome-specific web apis [1]), no one is even remotely surprised to see such results, because by now people just assume Chrome to be a beast. And Chrome has in the past been the most RAM-eating of all browsers out there.
The graphs should be questioned, of course, but Chrome has already earned its reputation, and it's very hard to un-earn it.
[1] https://web-confluence.appspot.com/#!/confluence see "Browser-Specific" tab
> half the comments on the post, didn't question these _wildly_ different results though...
(Disclaimer: I worked on Chrome. I believe the conclusion "uses a lot of RAM" is correct, but it doesn't mean the reasoning that led to there is right.)
This means pretty much only using Firefox - but I have about 10 tabs open at the moment, each using over 500mb of ram while idle. What on earth they are doing I don't know... and I find it very sluggish when playing video.
Chrome is my daily browser, even after they limited the number of rules that ublock origin can use. But it grinds to a halt on my top of the range macbook pro and uses 100% cpu if I open a couple of twitch streams and 20-30 other tabs.
Safari is a joy to use, much better on battery but webextension implementation means ublock origin is not possible.
I’m not sure if the bug is in Firefox or in the sites, but it’s awful. I don’t understand how these issues don’t get fixed immediately. I thought for sure after the new reddit redesign landed that they’d iron out the performance issues in a month or two but I swear if anything it’s gotten worse.
Also, do you have an NVMe or Optane SSD attached?
Lately been using teddit.net for browsing reddit and it’s been great.
I use Firefox on windows and Ubuntu and yds it eats ram but I don't really experience any sluggishness or issues from this.
Adding up the RAM totals 671.7MB on a 16GB device. But why do I have one Firefox with 4 sub-processes, and 3 (no 4) additional lone Firefox processes? I think the 4 background processes must be extensions in sure, but then what is the primary process with 4 sub-processes when I only have two tabs?
Without extensions, it looks like the browser is using about 280MB.
I don’t know anything about Firefox’s specifics, but forking an already initialized process typically is faster than launching a new process, so if I were to write a multi-process browser, I might have an empty, initialized, process hanging around of every type that can be forked and then sent a message to load a page or extension.
Alternatively, Firefox could keep processes running on the decent chance that you will want to open a new tab soon.
15 FF tabs open currently: https://ibb.co/MRkJjwY
- 1 outlook email tab - 1-2 custom web apps for dev work - the rest are jira and gitlab
No matter how much I like Safari optimization, taking advantage of OS, eye candy, etc. - this is all SECONDARY to a full functional ublock origin.
This is non-negotiable.
Sigh. That's sarcasm if it wasn't apparent. And no I don't care if Typescript / ECMASCript v-latest "fixes everything".
The V8 devs are certainly doing yeoman's work, but at the same time that hard work enables all the JS insanity to get worse and worse, to say nothing of the advertising sociopaths, tracking cookies, and browser profiling.
I 100% agree that it should be a required feature of web browsers to limit RAM, disk, and CPU usage. Yes you can prompt for more resources, no you can't ask for unlimited.
Cue every website asking for that along with cookies, and not working otherwise. And of course, notifications.
I'd appeal to google to start enforcing good behavior, and maybe Apple, but that would be counterproductive
Is it that they don't realize Safari is a multi-process architecture, and they're only measuring Safari's main process?
But there’s something people need to take into account as well: there’s only so much browser developers can do to optimize the browser. Website developers need to do their part as well. And Google is by far the worst offender in this regard. Facebook isn’t much better.
Most Google-owned webpages you visit are going to use at least 500MB on Safari or 800MB on Chrome. This is nonsense! If they were to develop a native app with exactly the same features it would take at most 250MB of RAM for the largest pages (such as large spreadsheets) and it would be a lot faster.
Compare Google and Facebook webpages to almost any other webpage and you will see they use too much RAM. People are unfortunately getting used to thinking “oh, I have 8 tabs open, that’s too many” when in fact it shouldn’t be.
I know I’m a tab hoarder, I don’t deny that. But using Safari currently have over 13 windows open, each with at least 25 tabs, not to mention plenty of native software running and still have a very fast and functional Mac. It’s not like I have 2TB of RAM either: 16GB of RAM is more than enough to do that. About a year ago (before I upgraded) I did pretty much the same thing with a 8GB RAM 2013 Mac and still didn’t have issues.
The only tabs Safari ever tells me it has reloaded because it’s using too many resources are Google-owned websites. This doesn’t happen with any other website at all from the hundreds of tabs I have open.
If you want a browser for the web instead of a JS virtual machine you have to look backwards, not forwards.
Now if only there was a way to calm Twitter down...
I redirect all twitter links to nitter. For me nitter loads much faster.
I built an extension to do it: https://secretkeys.io/oldr/
But Facebook surprises me with removing Messaging functionality from mobile sites. So i must use desktop site. Within 5 minutes fans starts howling...
No need to load all of facebook.com
So the power consumption thing is quite the myth as well.
Obviously both claims can't be true. From what I remember with Edge (pre Chromium) and Firefox I'm going to guess Safari doesn't really use 1/10th the memory of everyone else - maybe I'm just not familiar though!
The Flotato test uses Twitter and Gmail (for the first set; it doesn't specify the sites used for the 2nd set). Both Twitter and Gmail are large, complex, slow webapps which likely do some sort of advanced active memory management (extensive use of service workers, local storage, etc.). They also load mainly (exclusively?) 1st party resources.
The Brave tests use a large varied set of sites[0], which seem to be a combination of simple news & ecommerce sites. There are no complex webapps in the list. Modern news sites do have a reputation for being slow and heavy, but this will mostly be due to 3rd-party resources from ad companies; the sites themselves are simple and lightweight in terms of 1st-party content.
So they seem to be comparing very different browser usage patterns.
Given that, and looking again at the Brave tests: Safari does actually have lower memory usage than Chrome for most of their graphs. It just creeps slightly ahead of Chrome in the later tests.
[0] https://github.com/brave-experiments/browser-comparison-tool...
Similarly, Google Docs & Sheets are abysmal currently; not really sure if they were ever significantly better or worse in the past.
In terms of webapps, Google's approach has always seemed to be to make things that are powerful, sometimes usable, but with no focus on performance, cross-browser compat, or general industry best practice at all from a frontend engineering perspective. Any engineering quality in Google products has never in my experience lived in client-side code. This is exacerbated by the fact that "code quality" drives in other companies are often sneaked onto managerial priority lists under the guise of SEO requirements, something Google have never needed to meet.
But also for reference, it’s not like something of Gmail’s complexity has to use that much memory. Fastmail provides equivalent functionality minus chat in a 10–15MB budget, and you can add calendars and contacts (which are separate in Google land) and still keep it to 16–25MB.
Funny how Firefox reports a third of that, although IDK if Chrome and Firefox task managers are directly comparable.
I’m playing on a Mac right now and see nothing like what is reported here. When I open cnn.com in Safari, that tab alone takes 1GB. Chrome reports far less usage than that.
Also “Real Memory” is not the same as active memory in RAM, it’s not necessarily giving a complete picture. Memory can allocated but unused or compressed or paged out.
But Chrome is simply not an efficient browser on Macs. Anecdotally, it uses more memory and measurably consumes more energy. The Mac's fan will run more when using Chrome, and you will need to charge more often. If you use a lot of tabs, your entire computer will slow down.
There's market validation for this assertion. There is a YC-backed company currently working on tech to offload Chrome tabs to the cloud so the browser uses fewer resources. This is not something that would be identifiable as a problem in Safari.
If you have access to a Mac, you don't need to take anyone's word for it. Just use Chrome for a few days and then use Safari for a few days. The difference is pronounced. If you use your browser heavily, you will notice.
Since password managers are in the news, Safari also syncs passwords to iOS devices (password sync also works in native apps). It's free.
Chrome is fine though, as long as you don’t open 20+ tabs. Beyond that it’s not fine.
I replaced Firefox with Chrome because it kept ranging from a great to terrible user experience with various updates.
This is all anecdotal and based on personal experience.
On iOS I mostly use Safari even though that is kind of against my synchronised argument, but it works alright as I have found that I use my phone for very different web things.
(In case you're interested…)
iCloud for Windows now does bookmarks and passwords sync. https://support.apple.com/guide/icloud/icloud-for-windows-ov...
For ad blocking, I really like 1Blocker. NextDNS is great as well.
It looks like their test includes plenty of ad heavy sites like news articles which seems to confirm that the results are cherry picked.
Any reason to trust the ram usage for Safari nowadays?
I tried disabling javascript a few years ago and the entire web broke. Tried it again last year and have had much more success.
In the process, I've found a strong correlation between quality of content and quality of interface accessibility. When a site makes me jump through hoops to view the content, be it enabling JS, video DRM, paywalls, or modal overlays, the content is typically of low quality as well, and I feel like I actually gain more from avoiding it than from going through the trouble of accessing it.
But what I can say for sure is that in real-world use, on Mac, Safari absolutely feels lighter weight than other browsers. The fans spin up less, the battery lasts 30% longer, and other apps seem to be more responsive. I don't know if that's memory or cpu or what have you, but it's real.
You do pay a price in actual page-load times. Chrome absolutely has a small but noticeable edge in raw browsing speed.
I suspect this comes largely from Safari's tight integration with the rest of macOS. I recently had occasion to read a bit of Chromium's Cocoa UI code (to help the developer of https://github.com/blueboxd/chromium-legacy track down some bugs), and my very surface-level interpretation of what I saw could be summed up as "how can we get rid of macOS's native functionality and use our cross-platform stuff instead?"
But from the same anecdata experience, what happens when it’s not is awful.
So the significant difference between Safari’s and Chrome’s model is how tabs are pooled into subprocesses. Safari quickly groups same-origin tabs into the same process which has a huge memory cost advantage. Chrome very aggressively spawns subprocesses per tab up to some pressure metric before it starts sharing processes across tabs, which consumes more memory but much more readily frees it too.
Safari’s model is basically more shrewd and probably better for average users, but the pathological case is GBs of unused memory with unclear priority and total system stalls. Chrome’s pathological case is much easier to reach but much easier to recover from because for the most part closing or killing a bad tab process fully relieves its resource pressure.
And chrome's UI is much more fancy, displays way more data, and has way more functionality, than the UI that was powered by the 4kb of ram.
It's a cute comparison, but ultimately, it's meaningless.
>Using sleeping tabs on Microsoft Edge typically reduces memory usage by 32% on average. It also increases your battery life as a sleeping tab uses 37% less CPU on average than a non-sleeping tab. Although individual device performance varies depending on configuration and usage, we’ve heard from users that this decrease in resource and battery usage has improved their browsing experience.
https://blogs.windows.com/msedgedev/2020/12/09/sleeping-tabs...
https://addons.mozilla.org/en-GB/firefox/addon/auto-tab-disc...
From homepage,
>From browser tab to magic Mac app. >Break free from the browser and add web pages to your Mac dock. How about a mac app for Gmail, Twitter, Instagram, Netflix, and literally millions more?
From their help page,
> Dig in to making real Mac apps from websites with Flotato.
Looks like you can create apps of your websites. And it looks like it does it using Safari's engine.
So far this has worked consistently for more or less every site I tried.
I am not sure what this product really achieves.
Measuring memory usage is hard.
Pretty neat huh?
I read some comments complaining about slowdowns and I just have to chuckle. You do realise computing technology grows exponentially with time, right? Your hardware is outdated by the time you get your hands on it, and only gets worse performance-wise as time progresses. This has been true in literally every era of personal computers.
You can't seriously expect a CPU from nearly a decade ago and, what I assume, barely 6GB of RAM to sustain your 10+ tabs, YouTube videos in HD/4K/etc, and your heavy workloads outside of the browser at the same time without some slowdown.
I'd agree that modern browsers (and applications in general) have become more resource hungry, but do you think these new and fancy features come without a cost?
If you're so concerned with memory usage, why not use wget instead of a browser?
The other thing to mention is that the functionality provided by Flotato can be mostly duplicated in Edge by just creating Edge apps for common webpages. I've done this with GMail, Youtube TV, Youtube Music, etc. There are sometime limitations (you can't have Outlook as an app and Outlook Calendar as an app), but it's pretty solid. These apps seems to bring down RAM and CPU usage, but I haven't measured formally.
Bonus: I have setup two different profiles in Edge - one for work and one for personal. What's nice is that if you create an app like Gmail under your personal profile, links from that app will always open in the associated profile - in this case my personal profile. This is, for me, absolutely groundbreaking but that's for me. In the past I've tried to use standalone email programs and it would constantly drive me crazy when I had, say, a personal and work inboxes, and then I click on a link in my personal email and it opens in a work browser window because that was the last one I clicked.
I've been testing Flotato and it seems really buggy - couldn't get many apps to even run.
Activity Monitor showed windowserver at about 50% CPU usage, Chrome at another 40%.
I thought Teams was enough of a hog, but clearly FB is worse.
I did not have time yet to schow whether the claims are true but i found this when searching why i have insanely high windowserver cpu activity.
Seems chrome on mac is heading into a strange direction. For normal browsing i use safari since a long time as the battery will last the longest compared to firefox and chrome. But the chrome developer tools are so damn good i can‘t get rid of it for development.
The Keystone thing though, it's not a panacea. It seems to fix the issue with WindowServer running away with the CPU, but Chrome is still pretty terrible. I decided to just deal with the switching cost and stopped using Chrome altogether. It has made all the difference. Switched to Firefox and I'm not looking back.
> focuses mainly on memory usage
I mean I get it, Chrome is not the most efficient browser out there and Safari is more efficient in terms of memory and power usage. I'd probably use Safari as my daily browser if I didn't depend on Chrome's dev tools.
What's the tradeoff though? Usually you sacrifice memory to spare the CPU, and vice versa.
Safari provides slightly less security in exchange for less resource usage, since some websites allow multiple user accounts to be logged in at the same time and Chrome will protect users data better in those scenarios.
https://www.chromium.org/developers/design-documents/process...
Back to the subject at hand: Chrome is a memory hog and there’s nothing new here, but nice to see the comparison with Safari. Too bad Firefox wasn’t part of the test.
https://www.opera.com/gx#gx-control
"Need every ounce of power your machine can give you? No need to close your browser. GX Control lets you set limits on how much RAM, CPU and network usage your browser takes up."
Nice specs (32GB RAM) but perhaps not representative of the norm.
HN audience wouldn't be too bad.
Edit: as of Feb 18, 2021, you can't even buy a 13-inch MBP with 32 GB of RAM. The 16-inch model with 32 GB of RAM and all other specs set to their minimum/default comes out to $2800 on the Apple online store. That is far, far outside the range of what most people have access to.
I'd love to use their product but this doesn't incite confidence.
There's a pretty elegant solution to this that basically all OS use these days: the OS can use additional memory as a disk cache, since IO is still the biggest bottleneck on most systems. Apps can request a file to be cached too (see man 2 readahead), so there's no guessing involved and the app can cooperate with the OS instead of assuming it's the only thing that is or ever will be running and eating up qll resources accordingly.
But it does get slower and slower with each update.
Any browser with a small memory footprint you should ask yourself "if someone manages to find a buffer overflow in this thing, will my bank password be sitting adjacent in memory because the memory allocator is trying to save RAM rather than being security conscious"?
That means an attacker has to find some memory safety issue and some code execution issue in the same object. They can't corrupt memory using one flaw and then get code execution by forcing another type of object to be allocated at the same place.
Learn more here: https://chromium.googlesource.com/chromium/src/+/dcc13470a/t...