Unusually High Swap in Mavericks?

Discussion in 'OS X Mavericks (10.9)' started by w00t951, May 8, 2014.

  1. w00t951 macrumors 68000

    w00t951

    Joined:
    Jan 6, 2009
    Location:
    Pittsburgh, PA
    #1
    I've noticed that Mavericks seems to swap out to the disk when it doesn't need to - memory pressure is a low linear line, and I've got 6.03GB/16GB used, with 277.8MB of swap used.

    According to this article, however, Mavericks isn't supposed to use swap memory unless you overrun your physical installed memory by several GB's.

    Can someone explain to me why swapping to the disk is preferable to keeping it all in RAM? Even with a PCIe SSD RAM is still thousands of times faster in read/write speed and latency. I'm barely using my RAM and OS X is still swapping out to the disk.

    Thanks.
     
  2. FreakinEurekan macrumors 68040

    FreakinEurekan

    Joined:
    Sep 8, 2011
    Location:
    Eureka Springs, Arkansas
    #2
    I sometimes see a small amount of swap like that - never seemed to cause problems. I ignore it unless it gets to 1GB or so.
     
  3. w00t951 thread starter macrumors 68000

    w00t951

    Joined:
    Jan 6, 2009
    Location:
    Pittsburgh, PA
    #3
    It's not the space that's the problem, it's the constant writing to the SSD. Solid state mediums have limited write/read capacity, and if the OS is unnecessarily swapping out to the disk it will shorten its lifespan.
     
  4. dmccloud macrumors 6502a

    dmccloud

    Joined:
    Sep 7, 2009
    Location:
    Anchorage, AK
    #4
    This shortened lifespan issue has been debunked on multiple occasions. While it was true for first generation SSDs, modern SSDs can last longer than the machines they're being used in. Testing has shown that even smaller SSDs can easily last 5-10 years through normal use (longer than most systems will be usable for), if not longer.

    SSD Life Expectancy Tested (Anandtech)

    Here is a graphic from the Anandtech article showing the lifespan of a couple different types of SSD assuming 10GB of data per day is written to the drive. Obviously, that will change if you write more or less data on a daily basis:
     

    Attached Files:

  5. yjchua95 macrumors 604

    Joined:
    Apr 23, 2011
    Location:
    GVA, KUL, MEL (current), ZQN
    #5
    Swapping a gigabyte or two a day isn't much, but if it swapped well over 10GB, I'd be worried.

    I remembered in a thread that I created, there was an errant feature in a software on my system that kept writing to my SSD (although it didn't use any swap). I have since disabled that feature.

    Anyways, here's a screenshot of my Activity Monitor (rMBP 13", 2.8 i7/16/512, 5h 25m since boot up). Workload was just Safari, Word, Spotify and Preview.
     

    Attached Files:

  6. h9826790 macrumors 604

    h9826790

    Joined:
    Apr 3, 2014
    Location:
    Hong Kong
    #6
    I don't 100% sure it's normal or not.

    I've seen similar question in somewhere. On a 16G RAM MacBook, no memory pressure, but a 238MB swap file created and stay there until reboot.

    Most user suggest that unless the swap file size keep increasing, otherwise nothing to worry about. This is inline with the Apple's suggestion (you need more RAM when memory pressure shows red and swap file size increase).

    And someone suggest that it may be a normal system activity, nothing related to the real swap usage. However, due to the system register those activity as swap file usage. The number just stays there.

    As far as I know, the swap usage will register ALL page in and out. 277.8MB is really nothing to worry about, and it is virtually doing nothing to the SDD ware.

    If you think that the system may keep read / write that 277.8MB swap file. That's not the case. Lets say the system crate a 100MB swap file, and then the system fully rewrite that 100MB file another 9 times, you may see the "swap used" shows 2000Mb in Activity Monitor (1000MB write and 1000MB read).

    Anyway, if you really very very care about that extra writing to your SSD, may be you can crate a RAM disk to replace the var/vm/ folder. But personally I won't recommend this, because it may destabilise the system in some situation.
     
  7. w00t951 thread starter macrumors 68000

    w00t951

    Joined:
    Jan 6, 2009
    Location:
    Pittsburgh, PA
    #7
    I haven't had any Swap Used since I rebooted, so I think it was a bug.

    And regardless of the durability of SSDs (those are merely projections; SSDs are so new that many questions go unanswered about true durability), it's still not something that should be happening.
     
  8. maflynn Moderator

    maflynn

    Staff Member

    Joined:
    May 3, 2009
    Location:
    Boston
    #8
    When in doubt reboot.

    Could it be a buggy app with a memory leak?
     
  9. h9826790 macrumors 604

    h9826790

    Joined:
    Apr 3, 2014
    Location:
    Hong Kong
    #9
    I've just intentionally run photoshop intensively (plus allow it to use 100% of RAM) to use up all the 32G RAM in my Mac. I monitor the swap usage through out the test, end up I have the following result.

    Screen Shot 2014-05-13 at 15.53.39.png

    The system squeezes out another 8G of RAM by compressing it. And push the virtual memory to 48G, but still have no swap usage.

    It seems Mavericks handling RAM really well. And won't touch the swap file unless it really required to do so. Therefore, I am quite sure that 2xxMB swap in your case is not a real swap by Maverick. It may occasionally happen, we don't know is it cause by memory leak of some other software. However, it shouldn't because of Maverick don't know how to use the RAM properly.
     

Share This Page