Browsers eating RAM

Posted by Morten Just

UPDATE

This got a lot more attention than it deserves. As I'm pointing out below, it's likely the case that the system tool I used for measuring memory footprint isn't giving the full picture. It's also not a very indicative test in terms of every day use. However, I do think the reason this resonated with so many people is that most of us have heard the fans cool down when they exit Chrome. I'll see if I can find a better way to measure that. Stay tuned on @mortenjust

I reached a point where I could barely hear the podcast I was trying to listen to. That's how loud the fan was. Then I closed down all open Chrome windows, and a few minutes after, the fan went silent. So I decided to see if it was just me.

How I measured

I ran the 2-tab test in a completely fresh macOS install on a virtual machine. Then I ran the 54-tabs test on my own Big Sur installation, but with all extensions disabled. To record a usage snapshot ~250 times per second, I used psrecord.

2 tabs: Twitter, then Gmail

To simulate a realistic environment, I did the same steps on Safari, then Chrome: Go to twitter.com, scroll around, then open a new tab with Gmail and open an email. A dot means I interacted with the system. You can hover a dot to see what I did.

10x RAM

Average real RAM usage using Twitter in a single tab. Flotato uses Twitter for mobile browsers. Running in a clean install on a virtual machine

Chrome reaches 1GB with 2 tabs

Real RAM and CPU (%) used when opening Twitter, then Gmail. Running in a VM

Safari stays below 80MB

Real RAM and CPU (%) used when opening Twitter, then Gmail. Running in a VM

Putting Flotato to the test

To be light-weight, Flotato doesn't just run a stripped down, Safari-backed web view, it also defaults to the mobile version if one is available. Here's Flotato compared to a regular session in Safari. Note the slightly lower CPU usage. It's kind of hard to put a finger on what exactly the mobile version isn't calculating that the desktop version is; the two versions are almost identical when you use them.

Safari

Real RAM and CPU (%) used when opening Twitter, then Gmail. Disabled extensions, not VM.

Flotato shaves off another ~10MB

Real RAM and CPU (%) used when Flotato is running Twitter for mobile. Disabled extensions, not VM.

54 tabs: the stress test

I bet you have more than 2 tabs open right now, I sure have more. So here's a stress test where I open 54 tabs while measuring the impact on my Mac's RAM and CPU. A dot means I opened a new tab. Hover the dot to see which site I opened.

24x RAM per tab

Average RAM used per open tab in a session with 54 tabs. Disabled extensions, not on a VM.

Chrome

Real RAM and CPU (%) used when opening 54 tabs. No extensions, not on a VM.

Safari

Real RAM and CPU (%) used when opening 54 tabs. No extensions, not on a VM.

Is it bad?

When I saw the results I got suspicious. Chrome was using way more memory than I thought it would. Maybe it was the virtual machine blocking Chrome's direct access to my Macbook's* GPU? I decided to run the next test, the one with 54 tabs directly on my own Big Sur installation. The results were, well, slightly worse.

The graphs don't tell the full story

But it's probably not as bad as it looks. It's not a terrible thing that an app actually uses your computer. And you've got to hand it to Chrome: it is fast!

I'm sure Chrome is going out of its way to manage its memory usage across tabs, keeping the current tab fast and responsive. That's great if you're not running any other macOS apps than Chrome, effectively using Chrome as your operating system, and macOS as a kind of bootloader.

But when you're using Sketch, Final Cut, Photoshop next to Chrome, that seems to be a problem. MacOS likely tries to tell Chrome to take it easy, and Chrome likely does take it easy. These graphs don't tell that story.

So no, it's most likely not as bad as it looks, but that doesn't change the fact since switching to Safari, I almost forgot what my fan sounds like.

And then there's this chart. As we can see, the two browsers heat up the computer almost to the exact same level - Safari even getting slightly warmer. This probably points to psutil not being able to see all Safari's child processes, but only the main ones — despite the fact that Activity Monitor is able to group them. That's a little confusing.

Image

* Macbook 16" from 2019 with2.4 GHz, 8-Core Intel Core i9 with 32 GB 2667 MHz DDR4 RAM and an AMD Radeon Pro 5500M 8GB GPU