It’s time for Safari to go on a memory diet

Safari is a very capable web browser, but it's too demanding of memory resources.

safari icon osx
Apple

I like Safari. I’ve used Apple’s web browser for most of my work since it was released. I do use Chrome and Firefox for certain tasks, but Safari is my default browser.

I like the way Safari has tabs, and how you can pin tabs to keep windows available all the time while only taking up a tiny amount of space in the tab bar.

I like Safari’s Reader feature, the way it connects with my keychain to store passwords, and the ability to sync bookmarks, favorites, and other data with my iOS devices.

But there’s one thing I don’t like about Safari: it’s a gourmand.

Right now, my iMac’s uptime (the time since my last restart) is nearly four days. And Safari is using 6.81GB of RAM, by far the largest memory hog on my Mac. The app itself is using about 1GB, but each tab, each window also uses RAM. You can see this in Activity Monitor (located in /Applications/Utilities), by selecting the Memory tab.

activity monitor

You can see each Safari tab and window and how much RAM it uses in Activity Monitor.

As you can see above, the most egregious RAM user is Google Docs, which requires more than 500MB RAM for a single, blank document. Open a few more Google docs, and you’ll see that number quickly balloon. (It’s not clear whether this is Google’s fault or Apple’s fault.)

A lot of this memory usage depends on how long the pages or tabs have been open. If I launch Safari on my 12-inch MacBook, and open the exact same tabs, it only uses 2.8GB RAM. Of course, if I leave them open for a long time, that RAM usage will increase.

istat menus

iStat Menus shows how much RAM my iMac is using, and how much each of the top five apps are using.

You can watch this RAM grow over time. I use iStat Menus ($18) to keep an eye on some of my Macs’ metrics, and if I check it from time to time, I’ll see that the amount of RAM used by Safari has gone up. As I write this, 15 minutes after I said above that Safari was using 6.81GB, that number has increased to 7.14GB. And it will continue increasing over time, as long as the same tabs and windows are open.

This isn’t necessarily a problem, given the way that macOS manages memory. Some memory is compressed, and some gets paged to disk (as virtual memory). Your Mac can effectively use more RAM than you have, if needed. (This Apple developer document explains how Macs use RAM; it’s not for the faint of heart, however.)

But virtual memory is not a panacea. When your Mac uses virtual memory, it writes some of the data that is ordinarily stored in RAM to your disk, in what are called “swap” files. And when it wants to recover that data, it has to read these files. Reading and writing to an solid-state drive is fairly fast (though much slower than doing so to RAM), but transferring data to and from a hard disk—especially the poky 5400-rpm disks that Apple ships with iMacs—can make your Mac sluggish.

The real problem arises when users are working with RAM-hungry applications, and Safari also sucks up a lot of RAM. The latest MacBook Pro has a maximum of 16GB RAM, which may be insufficient for “pro” users, but this is even more of an issue for owners of older Macs, especially those with little RAM or hard drives.

In order to improve overall performance on Macs, it would be useful to look at Safari, and find ways to limit its often excessive memory usage.

Related:
Shop Tech Products at Amazon