Swap files and Lion...is this normal?

Discussion in 'Mac OS X Lion (10.7)' started by astrorider, Feb 5, 2012.

  1. astrorider macrumors 6502

    Joined:
    Sep 25, 2008
    #1
    I usually have about 40GB free on my 256GB SSD, but since upgrading to Lion I've been occasionally getting messages that my drive was nearly full. A reboot clears the space. It turns out my swap files are going out of control. Shouldn't the system be deleting these swap files on it's own? Is this a Lion bug?

    [​IMG]
     
  2. parapup macrumors 65816

    parapup

    Joined:
    Oct 31, 2006
    #2
    Hmm. That's weird for sure - my install only has swapfile0. May be some app is leaking memory or it's the OS itself (less likely). Check this thread, 2nd last post to see if it helps.
     
  3. astrorider thread starter macrumors 6502

    Joined:
    Sep 25, 2008
    #3
    Thanks for your help! I'll keep an eye on Activity Monitor and see if I can see what's going on. I'm running the same applications as under Snow Leopard though (mostly Xcode and built-in programs), where I never saw anything like this. I expect a fair amount of swapping since I'm only running 2GB RAM...it's the fact that the system never cleans up after itself and eventually consumes my entire hard drive that's the issue.

    When I've looked at Activity Monitor before the only odd thing I've seen is that occasionally Xcode's virtual memory column will go from ~300MB one second to 2.1GB the next, but there's certainly nothing that explains using 40GB of swap files.
     
  4. parapup macrumors 65816

    parapup

    Joined:
    Oct 31, 2006
    #4
    Oh - 2GB! You sir are a brave person to do that with Lion and XCode :) Kidding aside, that certainly explains it. If your system has multiple disks you can try moving the swapfile to the bigger drive - I have no idea if this will work with Lion but it did with SL and might just be what you need.

    Aside from that - it might just be easier to upgrade to at least 4GB and if possible 8GB to reduce swap usage. HTH.
     
  5. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #5
    Launch Activity Monitor and click the System Memory tab at the bottom to check your page outs and swap used. Page outs are cumulative since your last restart, and swap used will fluctuate, but are also reset to zero when you restart your computer. The best way to check your RAM needs is to restart your computer and track page outs under your normal workload (the apps, browser pages and documents you normally would have open). If your page outs are significant (say 1GB or more) under normal use, you may benefit from more RAM. If your page outs are zero or very low during normal use, you probably won't see any performance improvement from adding RAM.

    Mac OS X: Reading system memory usage in Activity Monitor
     
  6. tkermit macrumors 68030

    tkermit

    Joined:
    Feb 20, 2004
    #6
    This is almost certainly due to a 3rd party app running wild and not Lion per se. Some process is having a gigantic memory leak. Do you have the HP Device Monitor installed perchance?
     
  7. astrorider thread starter macrumors 6502

    Joined:
    Sep 25, 2008
    #7
    Thanks for the suggestions. I don't see HP Device Monitor in my process list in Activity Monitor, but I do use an HP printer. Do these leaky programs show as consuming a significant amount of Virtual Memory in the Virtual Mem column in Activity Montor? The only thing I routinely see consuming a lot of Virtual Memory (more than 500MB) is Xcode.

    After a swap file is created, it's never deleted by the OS then? So this could just be related to the fact that under Snow Leopard my 2GB of RAM was enough most of the time, so swap files weren't being created. Under Lion, I'm using more than 2GB of RAM a significant amount of time and so RAM is being swapped out to these files that eventually consume my entire drive?

    I'm running on an SSD and honestly the system performs fine for my use. The only slowdowns I experience are right before the system pops up the message telling me I'm running low on drive space. Every few days or so I have to reboot to reclaim the space from all these swap files. I never saw anything like this under Snow Leopard, doing the same work, with a working uptime routinely of 30 days or more. Going back really isn't an option because I'm developing and testing apps that are using iCloud now, so Lion was needed.
     
  8. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #8
    Yes, all swap files are deleted upon restart.
    I'm sure with only 2GB of RAM, you had swap files in SL. You may be swapping more with Lion. Whether SL or Lion, swap files are eliminated upon restart.
    If you're running a small amount of RAM, as you are, having available drive space is critical. You should always have 10% of your drive free. More is better.
     
  9. agentphish macrumors 65816

    agentphish

    Joined:
    Sep 7, 2004
    #9
    Strange that I saw this thread just now since I JUST killed my sleep image and noticed there was 6 swap files for an unknown reason. I killed them too, rebooted to recovery partition and repaired disk on my ssd.

    I am wondering what's making these too. This is happening on my Air with the 256gb drive as well. I don't have much running in terms of 3rd party apps.
     
  10. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #10
    See post #5. That may help.
     
  11. agentphish macrumors 65816

    agentphish

    Joined:
    Sep 7, 2004
  12. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #12
    True, but it explains what's creating the swap files, since you asked.
     
  13. astrorider thread starter macrumors 6502

    Joined:
    Sep 25, 2008
    #13
    You're right of course. I was hoping the system was supposed to be deleting old swap files without requiring a reboot, but I'm already all too familiar with rebooting to reclaim the space.

    It just seems wrong that the OS would allow 40+ GB of swap files to accumulate because the system has 2GB but really needs something more like 3GB (an assumption based on using the same applications under Snow Leopard without anything like this over much longer uptime's). I guess some extra RAM use by Lion is enough to put my machine into an area where it's needed to swap much more frequently, and since these files aren't deleted without a reboot I'm in this situation now.
     
  14. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #14
    The size of swap files used will fluctuate up and down, but won't be completely cleared until restart. You can track it in Activity Monitor to see if there's a particular app which consumes RAM more than others.
     
  15. tkermit macrumors 68030

    tkermit

    Joined:
    Feb 20, 2004
    #15
    That's indeed how it works. Lion automatically deletes swap files when they're not needed anymore. The fact that you're accumulating them means that some process is still holding on to the memory - a lot of it. This is anything but normal.
     
  16. astrorider thread starter macrumors 6502

    Joined:
    Sep 25, 2008
    #16
    Interesting, thanks! I'll keep an eye on things in Activity Monitor and try quitting anything non-critical for work, and see if I can get this thing back under control.
     
  17. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #17
    You may find some helpful ideas here, to reduce system demands and swapping: Performance Tips For Mac OS X
     
  18. astrorider thread starter macrumors 6502

    Joined:
    Sep 25, 2008
    #18
    Thanks for the great reference. I didn't find anything too surprising on my system going through the list, but it did remind me to reinstall click2flash for Lion and I turned off some old widgets. I'll see if there's any change over the next couple days and report back. Thanks again!
     
  19. grahamperrin macrumors 601

    grahamperrin

    Joined:
    Jun 8, 2007
    #19
    Review

    Did you reach any conclusion?
     
  20. astrorider thread starter macrumors 6502

    Joined:
    Sep 25, 2008
    #20
    It was a persistent problem even after upgrading to a laptop with 8GB RAM, under both Lion and Mountain Lion. I just learned to deal with it by restarting when disk space started getting low. Sometimes I didn't notice how low the free space had gotten, and when you get down to less than 1GB or so the OS gives you an error that your startup disk is almost full.

    I've just recently upgraded to Mavericks, and so far I haven't noticed as much disk usage due to swap files. Apple does tout memory compression technology in their feature page for Mavericks, so maybe that's why...although I've had a few wake-from-sleep freezes that forced me to restart as well, and so I haven't had the machine running without a restart for enough days to judge whether the swap file accumulation is significantly improved yet.
     
  21. grahamperrin macrumors 601

    grahamperrin

    Joined:
    Jun 8, 2007
    #21
    To me your case seems extraordinary, I very strongly suspect an issue with third party software.

    We're (happily) way beyond Lion so I shouldn't continue under this topic, but thanks for the very prompt response.

    ----

    If ever you suspect that software on Mavericks is making troublesome use of memory, I recommend posting a question to Ask Different.
     
  22. ivnj macrumors 65816

    Joined:
    Dec 8, 2006
    #22
    I have sleep image and 3 swap files 0,1,2,. So ya my 10.7 has more than 1 swap file also.
     

Share This Page