Safari memory leak

Discussion in 'Mac Apps and Mac App Store' started by dmelgar, Dec 4, 2008.

  1. dmelgar macrumors 68000

    Joined:
    Apr 29, 2005
    #1
    Safari on my system running 10.5.5 develops a huge memory leak over time. I haven't found widespread reports of current memory leaks in Safari.

    Are others experiencing problems?

    If not, how can I go about figuring out whats causing the problem on my system?

    Safari is currently at version 3.2.1.

    I don't normally close down Safari. It tends to be up and running all the time. I sometimes have many tabs open, up to 10. I view videos, mostly flash. I use Safari for RSS feeds. I have safariblock installed to block ads.

    Generally while I use Safari, memory usage slowly creeps up until my system starts thrashing more and more and eventually I bring up Activity Monitor to see that Safari is consuming the entire machine.

    I'm running Leopard 10.5.5, Safari 3.2.1 on a Macbook with 2GB RAM.
    When Safari first starts I see memory usage of RSIZE 60MB, VSIZE 988MB.

    But over time, it grows. The other day when my system reached its limit, RSIZE was over 1GB and VSIZE was 4.5GB! It really was using up at least 2GB of virtual memory. The "swap used" field dropped by 2GB when I stopped Safari.

    Any suggestions appreciated. I'm being forced into using Firefox which I don't like as much. Firefox is not exhibiting memory leaks on my system.
     
  2. Aronnax macrumors regular

    Joined:
    Feb 18, 2008
    #2
    it is the usual behavior from Safari
    http://dotnetperls.com/Content/Browser-Memory.aspx
     
  3. BobZune macrumors 6502a

    Joined:
    Oct 26, 2007
    Location:
    USA
    #3
    As a workaround, you can try out Webkit (nightly builds from http://nightly.webkit.org/ - find a stable one and stick to it for a while, instead of daily updates) till further updates to Safari.
     
  4. dmelgar thread starter macrumors 68000

    Joined:
    Apr 29, 2005
    #4
    I've been using a nightly build since yesterday. May still be too early to tell if there's a leak or if its just somewhat better. After running for a day, Webkit is up to RSIZE 244 and VSIZE 1.4GB. That might be manageable if it stops growing, but its been slowly growing all the way up to this and doesn't seem likely to stop growing. But the rate of memory consumption growth seems less than with Safari 3.2.1.

    Meanwhile Firefox, which I have not used as much is running RSIZE 65MB and VSIZE 1GB and is very stable.
     
  5. stark4 macrumors 6502

    Joined:
    Oct 14, 2008
    Location:
    Florida
    #5
    yeah i'm having the same problem like OP also... i always left Safari open with alot of tabs including youtube. Safari will slow down then crash(close down by itself) and got the message whether i want to report that or not. btw my system has 4GB RAM

    i thought apple is very stable and i don't have to restart everytime to free up the memory like pc.:)
     
  6. dmelgar thread starter macrumors 68000

    Joined:
    Apr 29, 2005
    #6
    I've been trying the webkit build. There are still loads of memory leaks in there.

    On the webkit bug reporting site there are 35 bugs regarding memory leaks for Webkit/Safari. So it looks like its a pretty well known problem.

    Several days later, my Webkit is up to ~500MB RSIZE, 1.5GB VSIZE.

    I ran "leaks Safari" and it reported 83,000 memory leaks have occurred so far.
     
  7. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #7
    Hm... a lot of those need closing actually. The 4xxx and 5xxx numbered bugs almost certainly don't apply anymore for example (the code they refer to has likely been rewritten in the years since then).

    The interesting question for me is how much of the memory growth is due to leaks, and how much is due to other causes such as heap fragmentation. My suspicion is that leaks are probably not the primary culprit, but that's just based on past experience not any hard data in this case.
     
  8. dmelgar thread starter macrumors 68000

    Joined:
    Apr 29, 2005
    #8
    Why doesn't Firefox exhibit memory growth? Shouldn't it experience the same issues with heap fragmentation?
    Doesn't the 83,000 leaks identified by "leaks" indicate that there are lots of leaks?
     
  9. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #9
    Firefox does, in many cases, although Firefox 3 is much improved in that respect. Drop by the mozillazine forums some time and browse around, there's almost always someone complaining about it.

    Yes, the leaks output is suspicious. Have you tried a more recent nightly? It's possible someone regressed that in the build you had, I certainly am not seeing it in mine.

    <edit> Feel free to drop the leaks output in my mail if it's still occurring in the latest (catfish.man@gmail.com) and I'll see about filing a bug. </edit>

    <edit2> https://bugs.webkit.org/show_bug.cgi?id=22753 may be what you're running into. There was some discussion of it on #webkit tonight, and in some situations it can lead to leaking a ton of JS objects. Dmitry (on the Chrome team) has a fix in progress. </edit2>

    <edit3> The aforementioned bug was fixed today, but doesn't match up with the leaks I was sent (which appear to be objective-c objects, oddly). </edit3>
     
  10. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #10
    Definitely try the latest nightly. A fix just went in to track the size of cached resources more accurately, which should avoid unbounded cache growth. So far it's behaving quite well for me :)
     
  11. dmelgar thread starter macrumors 68000

    Joined:
    Apr 29, 2005
    #11
    FYI. I'm trying the latest nightly build and I've uninstalled the plugins I had. Memory usage still seems to quickly exceed Firefox, but it has been able to come down after closing windows. I haven't used it much yet but so far it seems pretty reasonable. Running leaks only shows 22k bytes leaked.

    FYI. I've been running Firefox the last few days and it has stayed very well behaved. Memory usage peaked at RSIZE 170MB and VSIZE 650MB.
     
  12. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #13
    Hmm... my copy of the latest nightly has been between 80 and 150MB, currently 113. I wonder what's different. What numbers are you seeing, and on what pages?

    Source? As a WebKit developer I can certainly point you to a large number of areas Gecko is trailing in... ;) I agree they're doing great work though. Firefox 3.1 is looking sweet.
     
  13. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #15
    Fair enough. I suppose if you're willing to put up with NoScript you can dodge some XSS attacks and such.
     
  14. dmelgar thread starter macrumors 68000

    Joined:
    Apr 29, 2005
    #16
    I don't like Firefox on the Mac. On Windows its ok, but on the Mac they've refused to integrate with Mac facilities. Keychain in particular irritates me. Why it is necessary for Firefox to replicate keychain functionality? It seems simple to me to have an interface in Firefox where it uses its own on Windows but keychain on the Mac. Same thing with the dictionary, why replicate when Mac OS X already has a built in dictionary.
    Firefox also downloads by default to desktop instead of downloads.
    I do not like Firefox's default behavior for auto completing URLs. I don't like the searching. Its also strange to me that Firefox has a ton of configuration parameters that you can only get to if you know the magic URL.
    Firefox also was coming up full screen all the time. I googled how to fix it, but its a bad start.

    Regarding the Safari memory leak...
    It looks like most of my problem was caused by an older version of Safariblock which was leaking profusely. Now with a recent nightly build and a new version of Safari block memory consumption seems reasonably well contained. As I speak, Safari is using 115MB.
     
  15. Aronnax macrumors regular

    Joined:
    Feb 18, 2008
    #17
    - Replicate keychain functionality
    For example: You can sync you data with stuff like https://addons.mozilla.org/en-US/firefox/addon/2410
    or http://labs.mozilla.com/2007/12/introducing-weave/
    for free. When Firefox would use Keychain, would it not be possible.

    ---

    - Built in dictionary:
    OS X supports only 18 languages, but Firefox more than fifty. Therefore
    ---

    - Firefox also downloads by default to desktop instead of downloads

    A bug, but you can change it easily ;-)
    ---
    - I do not like Firefox's default behavior for auto completing URLs.

    It is also possible to change the auto complete behavior.

    ----
    - I don't like the searching

    Yes? Safari use the same stuff. Where is the problem?
    ---

    - Firefox has a ton of configuration parameters that you can only get to if you know the magic URL.

    Nobody will force you to use this nerd stuff, but you can use this nerd stuff. Where is the problem?

    ---
    - Firefox also was coming up full screen all the time.

    Even Firefox has bugs - here is one more ;-)
    -----

    - It looks like most of my problem was caused by an older version of Safariblock

    Most of you memory problems are for sure simply caused by Webkit bugs and not from other Safari extensions.

    Cheers
     
  16. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #18
    The leaks were Objective-C objects, WebKit is almost entirely C++. WebKit has its own issues, but his specific issue was elsewhere.
     
  17. INBLUT macrumors newbie

    INBLUT

    Joined:
    Jan 5, 2009
    #19
    I just read that it is not recommended to replace webkit from leopard for with Nightly builds.
    Is this so?

    I bought my 24" imac 2 days ago and safari also eats a considerable amount of ram.

    I ordered 4 gb of crucial this morning but will not turn my back at a better/faster/lighter browser

    Apart from the looks, which is the fastest and securest browser to use?
     
  18. dmelgar thread starter macrumors 68000

    Joined:
    Apr 29, 2005
    #20
    I still like Safari best as it does the best job integrating with Mac OS X. Reuses keychain, dictionary, etc.
    This thread is about safari leaking memory. Most browsers use lots of memory, but Safari's memory usage keeps growing over time as its being used. Easiest thing to do is to quit Safari once a day.
    The nightly Webkit builds are significantly better, but still after several days I ended up with it using 1.4gig of memory. Leaks reported minimal leaks, which obviously isn't true if its using that much memory with no windows open.
    My problem was caused primarily by the version of Safariblock that I was using. Safariblock blocks ads. I couldn't surf without it. A newer version has few if any leaks.
     
  19. dolphin842 macrumors 65816

    Joined:
    Jul 14, 2004
    #21
    Sorry to say, but Safari has never given up the physical RAM that it takes while open. It's done that forever. I have just resigned myself to relaunching it once every day or so. The only time I saw Safari give back memory was when closing out a Silverlight video page. The same thing happens to me in Firefox too, so I'm not sure what if anything can be done.
     

Share This Page