Home
Posted By: tacit Safari 5.1 Thrashing - 08/02/11 10:37 PM
I've been using Safari 5.1 for a while now, and for the most part I like it, except for a memory/swap management problem I've been seeing whenever I start to tax it.

Safari 5.1 separates the renderer from the rest of the browser, and runs the renderer in its own process, sandboxed from the computer. This is a security change; if someone discovers and exploits a bug in the renderer, it can't be used to do things like execute code or download files.

The problem seems to be in how Safari manages memory for the renderer. When I open a lot of windows or tabs (I will often have 40-50 sites open at a time) and when I'm low on memory (for example, running Photoshop and InDesign at the same time as Safari), my disk use will skyrocket and Safari will slow to a crawl. And when I say "slow to a crawl," I mean put one word on the screen, then put up the spinning beachball for 15-20 seconds, then draw another word, then put up the beachball again.

Looking at Activity Monitor when this happens shows that Safari and Safari Web Content (the renderer) keep trading spots for the top CPU usage. The number of pageouts skyrockets. It seems that what is happening is the system is swapping the renderer into memory, rendering a small part of the page, swapping the renderer out to disk and swapping Safari into memory, displaying what it's rendered, swapping Safari out to disk and the renderer into memory, rendering the next bit of the page, and so on.

Anyone else noticed this issue?
Posted By: MicroMatTech3 Re: Safari 5.1 Thrashing - 08/03/11 01:50 AM
Tacit,

I have seen odd and unexpected beachballs in Safari since I upgraded to Lion, with as few as four pages open. One of the additional pages is often www.msnbc.com, which may require more memory than most pages.

I have Safari configured to log in automatically at the MicroMat Forums at launch, and iCab configured to log in to the FineTunedMac Forums at launch. If I open additional pages in each browser, using bookmarks common to both, the responses of the browers are markedly different.

Now that you have posted your observations, I will check Activity Monitor and see if my experience is the same as yours, making use of the Disk Activity tab to check pageouts. There is definitely some new problem here.
Posted By: tacit Re: Safari 5.1 Thrashing - 09/22/11 03:18 AM
And it gets more interesting.

There definitely appear to be some issues in the Safari separation of the application from the sandboxed Web renderer. I've seen the renderer thrash or lock up even in non-low-memory conditions.

And here's something even more interesting. Every now and then, when the renderer thrashes, all my Safari windows will go blank, then reload. I assume this is the renderer either quitting and being restarted, or crashing and being restarted.

Either way, when this happens, all session information is lost. Web sites that I was logged into, I'm suddenly no longer logged into. Forms that I had filled out vanish--aggravating when it happens while I'm in the middle of doing something.

The first couple of times it happened, I wrote it off as an aberration, but these days, when I have about 30 windows open (which I usually do), it happens about once a day.

Anyone else notice this?
Posted By: joemikeb Re: Safari 5.1 Thrashing - 09/22/11 01:55 PM
As far as I know I have not encountered the blank and reload problem you describe but I often encounter page/window freezes where Safari refuses to accept any new input of any kind. In fact that happened just now as I was typing this post. The only "fix" I have found is to quit and restart Safari. There are several long threads about this on Apple's Safari Discussion.

Other than that I like Safari 5.1.
Posted By: ryck Re: Safari 5.1 Thrashing - 09/22/11 03:34 PM
Originally Posted By: tacit
Anyone else noticed this issue?

I have not although it may have to do with the fact that I don't usually operate with many open windows (3 or 4 at most). If I'm working between more sites I make use of the new feature, Reading List, which I quite like.

ryck
Posted By: artie505 Re: Safari 5.1 Thrashing - 09/23/11 07:18 AM
My main issue with Safari 5.1 is its memory leak.

> Every now and then, when the renderer thrashes, all my Safari windows will go blank, then reload.

I think I experienced that once, but the details of what happened are lost in time.

Edit: What happened was I all of a sudden realized that Safari's memory usage had dropped dramatically without my having quit an relaunched, and I think I lost my open windows as part of the deal. (I also think that both Safari's and the renderer's memory usage dropped.)
Posted By: tacit Re: Safari 5.1 Thrashing - 09/24/11 08:24 PM
That's interesting. I'll have to keep an eye on Safari's memory usage, but it certainly makes sense. If it's true, it suggests that the memory leak is in the renderer, and that if the renderer crashes or restarts, it reclaims the leaked memory at the cost of all current session information.
Posted By: artie505 Re: Safari 5.1 Thrashing - 09/24/11 09:40 PM
At the moment, Activity Monitor shows:

                                                 Real                        Virtual
                                              Memory                     Memory

Safari Web Content artie 0.0 301.2 MB Intel (64 bit) 341.4 MB 17091 6

and

Safari                      artie 0.3 147.9 MB Intel (64 bit) 223.3 MB 17090 11

My recollection is that "Web Content's" real memory usage always (Edit: greatly) exceeds "Safari's."
Posted By: dkmarsh Re: Safari 5.1 Thrashing - 09/24/11 11:13 PM

You might want to provide some context for those figures by telling us how much installed RAM you have.
Posted By: artie505 Re: Safari 5.1 Thrashing - 09/25/11 01:16 AM
Originally Posted By: dkmarsh

You might want to provide some context for those figures by telling us how much installed RAM you have.

4Gb RAM installed; thanks for thinking of that.

Edit: I should have supplemented that by mentioning that I had quit and relaunched Safari not too long before I took that Activity Monitor reading; immediately after launch, "Safari" uses less RAM than does "Web Content," but it doesn't take very long before they reverse positions. (When I quit Safari last night, WC and S were using around 870 and 170Mb of RAM, respectively.)

Note: Safari 5.1, in and of itself, makes MemoryStick* a useful desktop appurtenance; it's kinda fascinating watching the "Active" segment of the graph grow as quickly and as large as it does.


*) MemoryStick is no longer available at this location. The following direct download link still works: http://sbc.apeth.com/downloads/MemoryStick1.5.zip
Posted By: artie505 Re: Safari 5.1 Thrashing - 09/25/11 02:49 PM
OK... It happened again, and this time I've got a handle on what it was that happened:

1. I quit and restarted Safari, and "Safari"and "Safari Web Content" showed respective "Real Memory" usage of 94.5 and 44.2Mb.

2. 7 hours later, with "Safari"and "Safari Web Content" showing respective "Real Memory" usage of 199.1 and 423.6Mb (Note the reversal.), I put my MacBook (OS X 10.6.8/Safari 5.1) to sleep.

3. 3 hours later I woke my deuced Mac(hina) from sleep and hit control-S (my Safari hot key) to bring Safari to the front, and the open page (It happened to be the FTM Forums Index.) began to appear, then, all of a sudden, disappeared and was replaced by a new, empty page that turned into the FTM Forums Index.

4. Realizing what had happened, I immediately looked at Activity Monitor and saw that "Safari's" and "Safari Web Content's" respective "Real Memory" usage were 199.5 and 47.8Mb...that while "Safari's" was essentially unchanged, that of "Safari Web Content" had dropped to more or less its launch level...your renderer crash!

Edit: By the way... Remember that you can revert to Safari 5.0.5 by running the 10.6.8 Combo.
Posted By: artie505 Re: Safari 5.1 Thrashing - 09/26/11 08:20 AM
I forgot to mention that that last incident occurred with only one window, with one tab, open.
Posted By: tacit Re: Safari 5.1 Thrashing - 09/26/11 07:43 PM
Originally Posted By: artie505
OK... It happened again, and this time I've got a handle on what it was that happened:


Interesting. So that pretty much confirms what I'd suspected--when the renderer stops or crashes, memory is reclaimed, but all the session information is zapped into oblivion in the process.
Posted By: Kevin M. Dean Re: Safari 5.1 Thrashing - 09/30/11 08:32 PM
When the Web Content Process crashes it will cause all open tabs to reload when viewed.

I don't often have that problem anymore but I use the Webkit Nightlies which may have resolved those crash issues. So if you have a lot of tab reload issues, you may want to download the latest to see if it improves things for you.

http://nightly.webkit.org/
Posted By: artie505 Re: Safari 5.1 Thrashing - 09/30/11 10:33 PM
Thanks for reminding me about that link.

I've only experienced the Safari Web Content crash twice, but I'm curious to see whether anything has been done about its memory leak.
Posted By: artie505 Re: Safari 5.1 Thrashing - 10/02/11 07:32 AM
I d/l'ed the WebKit Nightly Build that was available when you posted, and, although it appears that Apple has made headway in dealing with the Safari Web Content memory leak, I didn't run it for very long...

1. I guess it's a function of the way my system is set up, but I repeatedly wound up with duplicate processes, i.e. WebKit/Safari Web Content and Safari/Safari Web Content, with which I didn't care to deal.

2. Something kept messing with my AdBlock For Safari database in /Users/Your short name/Library/Safari/LocalStorage, almost costing me considerable time and effort. (I'm going to start a new thread about that.)
Posted By: Kevin M. Dean Re: Safari 5.1 Thrashing - 10/03/11 06:00 PM
Originally Posted By: artie505
I d/l'ed the WebKit Nightly Build that was available when you posted, and, although it appears that Apple has made headway in dealing with the Safari Web Content memory leak, I didn't run it for very long...

1. I guess it's a function of the way my system is set up, but I repeatedly wound up with duplicate processes, i.e. WebKit/Safari Web Content and Safari/Safari Web Content, with which I didn't care to deal.

2. Something kept messing with my AdBlock For Safari database in /Users/Your short name/Library/Safari/LocalStorage, almost costing me considerable time and effort. (I'm going to start a new thread about that.)


1. That just sounds like you may have been running both Safari and Webkit at the same time. I don't see multiple Safari Web Content processes.

2. I'll be posting some further notes in your other thread.
Posted By: artie505 Re: Safari 5.1 Thrashing - 10/03/11 07:12 PM
> That just sounds like you may have been running both Safari and Webkit at the same time. I don't see multiple Safari Web Content processes.

Ultimately, I was, but I never started out that way... I'd launch WebKit, and later, by way of example, do a Google search that would, without my realizing it, launch Safari, thereby leaving me with four open processes when I only wanted two...free RAM doesn't last very long under those circumstances.
Posted By: Kevin M. Dean Re: Safari 5.1 Thrashing - 10/03/11 07:46 PM
You may have clicked some externals links that launched your default browser of Safari. To get around that, just open Safari's preferences -> General and set the Default web browser to Webkit.
Posted By: dkmarsh Re: Safari 5.1 Thrashing - 10/03/11 10:40 PM

I think if you initiate a Google search by right-clicking on a highlighted word or phrase and then choosing Search with Google from the contextual menu, though, the search is carried out via Safari regardless of your default browser setting. That contextual menu command seems to be hard-wired to Safari.
Posted By: Kevin M. Dean Re: Safari 5.1 Thrashing - 10/03/11 10:54 PM
That's no the case on my end. It opens within Webkit and doesn't launch Safari.
Posted By: artie505 Re: Safari 5.1 Thrashing - 10/04/11 07:36 AM
Originally Posted By: Kevin M. Dean
You may have clicked some externals links that launched your default browser of Safari. To get around that, just open Safari's preferences -> General and set the Default web browser to Webkit.

Good thought; thanks.

I think, though, that I'll stick with Safari for the time being; WebKit's RAM usage didn't appear to have improved all that much, and my browsing habits make it a "no-hassle" to quit Safari periodically.

And, in a different vein, I know myself, and I don't want to get (neurotically, as I do) involved with anything that changes nightly unless it's an absolute necessity.
Posted By: jchuzi Re: Safari 5.1 Thrashing - 10/12/11 11:11 PM
Supposedly, Safari 5.1.1 addresses the memory issue.
Posted By: artie505 Re: Safari 5.1 Thrashing - 10/13/11 08:24 AM
This is, of course, a pretty short-term observation, but Safari 5.1.1's memory usage has been reasonable so far...no evidence of a leak. smile

Edit: A coupl'a hours further down the road, and Safari 5.1.1 is still very well- behaved RAM-wise...exceptionally well-behaved, as a matter of fact.
Posted By: Pendragon Re: Safari 5.1 Thrashing - 10/13/11 02:10 PM
Originally Posted By: artie505
This is, of course, a pretty short-term observation, but Safari 5.1.1's memory usage has been reasonable so far...no evidence of a leak. smile

Edit: A coupl'a hours further down the road, and Safari 5.1.1 is still very well- behaved RAM-wise...exceptionally well-behaved, as a matter of fact.


That's good to know Artie, thanks!

Now, I'll have to break the habit of relaunching Safari twice a day. cool
Posted By: artie505 Re: Safari 5.1 Thrashing - 10/15/11 06:33 AM
Update: Well... Reasonably well-behaved, at the least; actually, I'm not at all certain what might be considered optimum RAM usage for Safari.

Anybody?
Posted By: joemikeb Re: Safari 5.1 Thrashing - 10/15/11 06:56 PM
I don't know the optimum memory usage for Safari, but the frequent page hangs I was encountering have disappeard. grin
© FineTunedMac