OS X Lion Bug: Safari guzzling massive amounts of RAM

After installing OS X Lion last week, one of the things I've noticed is that Safari tends to run away with enormous amounts of RAM over time. A subprocess called "Safari Web Content" will sometimes use over a gigabyte of RAM. Since my Mac maxes out at 4 GB, and since it's a rare day that I'm only using Safari and nothing else, having so much of my system's RAM gobbled up by one process was bogging everything down.

Safari Web Content is a sandboxed subprocess of Safari that runs all webpage rendering. If you've got several dozen tabs open at once, it might make sense for the subprocess to use up that much RAM; however, I was seeing huge amounts of RAM usage even with only three or four tabs open. Four webpages shouldn't be consuming over a gigabyte of RAM. Many people's knee-jerk reaction has been to blame Flash for the excessive memory consumption, but that's not the case here; Flash runs as its own separate process and has nothing to do with the "Safari Web Content" process or its runaway RAM usage.

A few people have recommended disabling any Safari extensions you may have running to reclaim a big chunk of the RAM used up by Safari Web Content. Whether it's a bug in Safari 5.1 or incompatibility with older extensions, the theory goes that one or more of the extensions I've been running was the cause for Safari's excessive RAM usage. Disabling all but a handful of my Safari extensions brought the Safari Web Content subprocess's RAM usage down from 1.06 GB or more down to a much more manageable 300 - 320 MB with five tabs opened, but over time usage climbed to over 600 MB again, so it's possible one of my enabled extensions is the culprit.

As I write this, it's been around ten minutes since I restarted Safari the last time. I have only three extensions running -- Better Facebook, Rapportive, and ClickToFlash -- and I've browsed about ten pages between three tabs since relaunching Safari. Already Safari Web Content has consumed nearly 300 MB of RAM.

A subsequent test with all extensions disabled has caused Safari Web Content to go from its initial 148 MB all the way up to 251 MB of RAM after browsing 39 webpages -- most of them on Wikipedia, which isn't exactly known for data-heavy content. This doesn't seem normal to me.

This bug definitely seems to have been introduced in OS X Lion or Safari 5.1, and hopefully it's one we'll see addressed in a forthcoming update.