Safari Memory Leak

Discussion in 'OS X and OS X Apps' started by viral_variance, Apr 5, 2008.

  1. viral_variance

    Joined:
    Mar 16, 2008
    Messages:
    512
    Likes Received:
    0
    Gender:
    Male
    Hi All,

    I noticed that my Safari is consuming a minimum of 200MB everytime i use it as a browser and sometimes reach 500MB at its peak. Now 500MB is quite big already for a 2GB RAM machine.

    I've now shifted to Mozilla, which also has its own share of memory leak but not as bad as Safari!

    My question would be: i love to use Safari, but i hate its memory leak issue. I want to ask if anyone is aware of any configuration that would resolve its issue? i can't find any application that might be able to handle garbage collection etc...

    Thanks :)
     
  2. RommelReyes

    RommelReyes Active Member

    Joined:
    Sep 1, 2007
    Messages:
    1,174
    Likes Received:
    0
    Location:
    Parañaque City
    what makes you think it's a memory leak?
     
  3. Chito Limson

    Chito Limson Unfrozen…
    Staff Member

    Joined:
    Apr 16, 2007
    Messages:
    8,982
    Likes Received:
    853
    Gender:
    Male
    Location:
    Miles ahead of you
    I'm running Safari now and Activity Monitor (/Utility/Activity Monitor) shows that Safari is using 89 Mb of Real Memory and 900 Mb of VIrtual. Right now, I have 4 tabs active - AOL, PhilMUG, GMail and Google Reader. I opened a fifth one, YouTube and run a random video - Real Memory is up 113 Mb and Virtual, 931 Mb. Plug-ins, Java and JavaScript are all enabled. I closed the YouTube tab and the memory consumption parameters are still both up (actually increased a bit in fact). I guess that's memory leak…

    FYI, I'm using Safari 3.1, the buggiest Safari iteration to date.

    EDIT:

    I'm shut down Safari and running Firefox 2.0.0.13 now for an unofficial comparo - same tabs, same video.
    Real - 105 Mb
    Virtual - 933 Mb

    I closed three tabs and the memory usage didn't change much either, although it's lower than that consumed by Safari (even if I have the same plug-ins plus a few more Firefox-specific Add-Ons).
     
    #3 Chito Limson, Apr 5, 2008
    Last edited: Apr 5, 2008
  4. RommelReyes

    RommelReyes Active Member

    Joined:
    Sep 1, 2007
    Messages:
    1,174
    Likes Received:
    0
    Location:
    Parañaque City
    don't you think it's possible that the leopard 'janitor' (the os x memory cleanup function) is causing the problem, since both safari and firefox did not 'release' memory after they had closed? most of the time, the app that exhibits the symptom is not the app that caused the problem.
     
  5. viral_variance

    Joined:
    Mar 16, 2008
    Messages:
    512
    Likes Received:
    0
    Gender:
    Male
    well if Safari did not release the memory that it was supposed to let go, then as a 1st level interface, it is already at fault. Mozilla itself has acknowledged that it has this kind of issue.

    anyway, until safari fixes the problem, i'll stick with mozilla
     
  6. RommelReyes

    RommelReyes Active Member

    Joined:
    Sep 1, 2007
    Messages:
    1,174
    Likes Received:
    0
    Location:
    Parañaque City

    can you point me to where mozilla admitted this memory issue? i would like to read it myself. thanks.
     
  7. Treb22

    Treb22 Active Member

    Joined:
    Sep 4, 2006
    Messages:
    2,682
    Likes Received:
    19
    Should we be bothered by this memory leak? How serious is this?
     
  8. lamski

    lamski PhilMUG Addict Member

    Joined:
    May 8, 2005
    Messages:
    2,892
    Likes Received:
    467
    Location:
    Makati, Philippines
    Guys, this is a common performance technique browsers use - they cache the last few pages in memory so that if you access the page again, the page is retrieved from memory instead of re-downloading it again from the web. If you close the tab, the page stays in memory for a while so you don't immediately see the cleanup in activity monitor.

    When I say "memory", I'm referring to actual RAM and virtual memory (hard disk caching). Applications normally don't have control when their in-memory RAM data is cached to disk. OS X does this on their behalf transparently.
     
    #8 lamski, Apr 6, 2008
    Last edited: Apr 6, 2008
  9. Chito Limson

    Chito Limson Unfrozen…
    Staff Member

    Joined:
    Apr 16, 2007
    Messages:
    8,982
    Likes Received:
    853
    Gender:
    Male
    Location:
    Miles ahead of you
    Not so serious (IF it's Safari indeed that's causing the memory leak) really, unless you're running several memory-hogging apps. You may run low on physical memory and thus, apps may slow down.
     
  10. Treb22

    Treb22 Active Member

    Joined:
    Sep 4, 2006
    Messages:
    2,682
    Likes Received:
    19
    thanks sir soloworx.
     
  11. RommelReyes

    RommelReyes Active Member

    Joined:
    Sep 1, 2007
    Messages:
    1,174
    Likes Received:
    0
    Location:
    Parañaque City
    excellent explanation lamski. thanks.

    from wikipedia :

    a memory leak has similar symptoms to a number of other problems, and generally can only be diagnosed by a programmer with access to the program source code; however many people are quick to describe any unwanted increase in memory usage as a memory leak, even if this is not strictly accurate.

    (boldface mine)
     
  12. Chito Limson

    Chito Limson Unfrozen…
    Staff Member

    Joined:
    Apr 16, 2007
    Messages:
    8,982
    Likes Received:
    853
    Gender:
    Male
    Location:
    Miles ahead of you
    Point well taken. Perhaps an expert programmer here at PhilMUG may want to share his views on the matter?
     
  13. briareos

    briareos Member

    Joined:
    Dec 19, 2006
    Messages:
    496
    Likes Received:
    0
    This could be simply how OS X manages its memory. I have no access to any source code, so this will be a simple analysis. OS X seems to be generous when allocating Real memory to applications. After a few hours of using your computer, your Free memory approaches zero while your Active and Inactive memory goes on the rise. OS X gives more memory to the apps that you use. That's to give you, the user, that creamy, buttery experience.

    Now when all that green Free memory is down to zero and an application, whether already running or newly started, requests for memory, OS X will have to take back some of the memory it allocated earlier. It can do this using many algorithms, I haven't delved deep into OS X, but OSs typically use Least Recently Used (LRU) or Least Frequently Used (LFU) to determine which memory to release. The data in that memory section gets written back to Virtual Memory. The memory section then gets released for use by another application.

    I think I'll stop there, before this turns out to be one of my OS lectures.

    If you want to recover your Real memory try http://www.activata.co.uk/ifreemem/
     
  14. RommelReyes

    RommelReyes Active Member

    Joined:
    Sep 1, 2007
    Messages:
    1,174
    Likes Received:
    0
    Location:
    Parañaque City
    so, for purposes of brevity: it's probably not a memory leak. more than likely, it's just the way the o/s handles 'things'.
     
  15. kaffee

    kaffee Active Member

    Joined:
    Aug 31, 2006
    Messages:
    1,576
    Likes Received:
    0
    Location:
    qc
    apple on OS X Memory Management:
    http://developer.apple.com/document...ry.html#//apple_ref/doc/uid/20001880-BCICIHAB

    More tech-speak on Memory allocation and memory leaks:
    Finding Memory Leaks: http://developer.apple.com/document...indingLeaks.html#//apple_ref/doc/uid/20001883

    "Memory leaks are blocks of allocated memory that the program no longer references. Memory leaks are bugs and should always be fixed. Leaks waste space by filling up pages of memory with inaccessible data and waste time due to extra paging activity. Leaked memory eventually forces the system to allocate additional virtual memory pages for the application, the allocation of which could have been avoided by reclaiming the leaked memory."

    Introduction to Memory Usage Performance Guidelines:
    http://developer.apple.com/documentation/Performance/Conceptual/ManagingMemory/ManagingMemory.html

    Technical Note TN2130: http://developer.apple.com/technotes/tn2005/tn2130.html

    Viewing Virtual Memory Usage: http://developer.apple.com/document...les/VMPages.html#//apple_ref/doc/uid/20001985
     
  16. viral_variance

    Joined:
    Mar 16, 2008
    Messages:
    512
    Likes Received:
    0
    Gender:
    Male
    sorry for my late reply. so apparently, it is not really a memory leak but more of a performance management utility made by the application.

    amazing, but still i find that it still consumes a lot of memory :( not really helpful when running lots of applications. Safari is still way ahead over Mozilla in terms of consumption, about 2-3x more than Mozilla

    anyway, as requested previously, Mozilla version prior to 1.5 suffers from the memory leak problem
     

Share This Page

  • About PhilMUG

    Since the mid-1990s, PhilMUG (formerly the Philippine Macintosh Users Group) has grown to become not just the Philippines’ but one of the world’s foremost Apple user groups. Our online community brings together thousands of members from the Philippines and around the world for the latest news and discussions covering all Apple products and related hardware and software. Anyone can join PhilMUG, from newbies to experts, subject to our membership rules and guidelines.
  • Like us on Facebook

  • Buy us a beer!

    The staff works very hard to make sure that PhilMUG is running 24/7. Care to buy us a beer or help out with our hosting fees? We'd really appreciate it!

    Donate to us!