Previous 1 2 3 Next 67 Replies Latest reply: Jun 23, 2013 9:25 AM by chef098
megagram Level 1 Level 1

Just bought a MBPr with 16gb of RAM (more for futureproofing than any actual need right now). I'm constantly checking Activity Monitor and "Free RAM" is always around 8GB or more. I notice, however, that the "Swap used" totals are quite high. I don't have any pageouts so why do I have so much swapspace being consumed? With an SSD drive in here, should I not be worried that the OS is using swapspace so much when it probalby doesn't need to?

 

Thanks!


MacBook Pro (Retina, Mid 2012), OS X Mountain Lion
Reply by etresoft on Jul 31, 2012 7:01 PM Helpful
Constantly? I wouldn't worry so much. Virtual memory in Mountain Lion is highly optimized - especially for SSD drives. Much of that swap space doesn't really exist. There is sophisticated fakery going on underneath to keep RAM-hungry applications from allocating memory they aren't really using.
Reply by nalundgaard on Aug 19, 2012 4:48 PM Helpful
Hi guys, I am very excited that I found this thread! I posted about the same issue in this thread about what appears to be the same issue—swap usage growing with no pageouts.  There's a lot of irrelevant discussion in this thread, IMO. I am not interested in the source of that side discussion, but I do want to say that I think that a critical point has been missed among people discussing this issue. Swap usage in OS X has long been the subject of much groaning and gnashing of teeth among users. Sometimes it doesn't make much sense. I've been using OS X for about a decade now, since OS X 10.2. I've suffered through many machines with woefully inadequate RAM for the memory hogs that various OS X apps can be, and the swapping that accompanies that. This is a hugely different issue. What the OP in this thread didn't realize was important is this: 3GB (or whatever) swap usage, and no pageouts. In my ten years of using OS X and seeing heavy swap usage, I have never, ever, not one single time, ever seen a system with swap usage that doesn't show at least a few pageouts. The issue that megagram clearly has and that I have had as well (as previously linked above) is a very unusual issue where the system writes (a very large amount of data) to the pagefile without registering a pageout. That sounds like a bug to me, any way you slice it. It's also totally different than some of the issues that follow-on commenters have mentioned. So... that's my take on that. I don't want to point any fingers or start flame wars, but I want to stress how different this issue is from run-of-the-mill swap problems.  Megagram, I wanted to ask you, how did you find that your fontworker process was causing the problem for you? I I tried resetting my font cache and deleting a coupld of old fonts that I don't use anymore. I still have MS Office 2011 installed, presumably with all the fonts that it installs. I don't know if that's still my problem, but I haven't even seen a "fontworker" process running or much history of one in my system logs. I do see fontd (presumably, the font daemon) running, but it seems to be behaving nicely. SOMETHING is causing a huge pagefile dump when I put my system to sleep and it goes into hibernate mode (that's the one where it writes the RAM contents out to /var/vm/sleepimage and powers down the RAM to save battery). I haven't figured out what yet. It doesn't appear to be fontworker in my case, so again I was wondering if you could give me some more insight as to how you tracked that one down? I'm thinking maybe I can use the same methodology to find my culprit. That said, I am very stumped—I've pored through log files around the sleep/wake event when the big page write seems to occur. I'm not seeing anything.

All replies

  • etresoft Level 7 Level 7

    Constantly? I wouldn't worry so much. Virtual memory in Mountain Lion is highly optimized - especially for SSD drives. Much of that swap space doesn't really exist. There is sophisticated fakery going on underneath to keep RAM-hungry applications from allocating memory they aren't really using.

  • Csound1 Level 8 Level 8
    expertise.desktops
    Desktops

    Do you have a virtual machine installed (Fusion, Virtual Box etc)?

  • megagram Level 1 Level 1

    Do you have a source for that information? I would love to read about it.. Thanks.

  • etresoft Level 7 Level 7

    megagram wrote:

     

    Do you have a source for that information? I would love to read about it.. Thanks.

    It is pretty standard practice for modern virtual memory systems. I have no idea where I saw it specifically. It was probably some developer documentation. Apple isn't doing anything particularly special. Pretty much all modern virtual memory systems work the same way. It is just that no other people obsess over the details like Mac users do.

     

    I can tell you that you should ignore any suggestions or adivce to try to change virtual memory in any way. As a developer, I have been running Mountain Lion for some time and using it heavily with Xcode. The virtual memory system in Mountain Lion is the best I have ever seen. There is nothing an end user can do to improve it - only damage it. If you are having problems, the cause is elsewhere.

  • megagram Level 1 Level 1

    K as far as I understood modern OS's, they write memory to disk when physical RAM is exhausted. My physical RAM has not been physically exhausted and yet I still see high numbers of pagefiles. This is my concern; especially since I have an SSD that can't be replaced I'd rather not accelerate its demise with unecessary writes.

     

    I'm not sure how you can say mountain lion's virtual memory is optimized for SSDs and that most of the swap space doesn't exist, even though it exists in the form of pagefiles without backing it up with concrete sources. Thanks, anyway.

  • Csound1 Level 8 Level 8
    expertise.desktops
    Desktops

    How about answering my question?

     

    See Below

  • megagram Level 1 Level 1

    Sorry I missed your question. I have VirtualBox installed but do not run it often (and when I do my VM only has 1GB allocated). As I say, my "free" memory in activity monitor never goes below ~8GB. I've been using Mac OS X since the 10.0 and am very familiar with the swap system. I'm just surprised to see any swapfiles when my memory usage is very minimal.

  • etresoft Level 7 Level 7

    megagram wrote:

     

    K as far as I understood modern OS's, they write memory to disk when physical RAM is exhausted. My physical RAM has not been physically exhausted and yet I still see high numbers of pagefiles. This is my concern; especially since I have an SSD that can't be replaced I'd rather not accelerate its demise with unecessary writes.

     

    That's the thing - it is way more complicated than that. That is how virtual memory worked 20 years ago. It is best to avoid looking too closely at memory values. When people do that they start seeing problems that aren't there.

     

    I'm not sure how you can say mountain lion's virtual memory is optimized for SSDs and that most of the swap space doesn't exist, even though it exists in the form of pagefiles without backing it up with concrete sources.

     

    I say that because Apple is moving to SSDs for their new machines, so that is where the focus is. Even with 16 GB, any application could exhaust your memory if allowed. MacOS X uses those swap files to keep that from happening.

  • Csound1 Level 8 Level 8
    expertise.desktops
    Desktops

    Virtual Box could still be the cause, try this: reboot, do not start VBox, give it an hour or so (doing whatever you normally do) and observe the swapfile, then add VBox to the mix and check again.

  • megagram Level 1 Level 1

    So I loaded up all my big memory users. I upped VBox's VM usage to 2GB to help speed along the process.

     

    I've been checking Activity Monitor regularly and the free mem has not once gone below 8GB (big green part of the pie).

     

    Just now I woke my MacBook from sleep and it hung for about 30 seconds. I checked the /var/vm folder and there are tons of swapfiles that were seemingly just created at that instant.

     

    Wonder what's going on. It's fair to say the last time I used my MacBook there were no swapfiles.

     

    Free memory has always been super high.

    Screen Shot 2012-08-02 at 4.38.17 PM.png

  • etresoft Level 7 Level 7

    I doubt you will have any luck stressing Mountain Lion's VM system. While running Xcode heavily I have been able to get my free RAM to less than 10 MB, but it recovered right away with no noticeable performance impact.

     

    You really don't need to worry about "swap used". I was unable to find a clear definition of entirely what this value represents. There are a number of possibilities, any or all of which are plausible. It could be memory-mapped files that are on disk to begin with but are now considered to be in memory. They could be initialization code like shared libraries that are in the application memory space but are shared. Therefore, there is no need to duplicate them in RAM. They can be permanently swapped to disk. They could be backing store of the application such that if it does need to be swapped, the OS doesn't have to worry about writing it. I don't know the real answer.

  • David A. Gatwood Level 3 Level 3

    I wouldn't worry about it unless you're seeing a corresponding performance hit.  If you are, then if you can reproduce it consistently, that might be worth filing a bug about or something.  Otherwise, it is probably just writing cold pages out to disk for performance reasons.

  • Nathan Goldshlag Level 1 Level 1

    Well I *am* seeing a slowdown.  With Snow Leopard there were 3 swapfiles totalling 256 M Bytes.  With Snow Leopard there are 6 files totaling 2 G Bytes, and I have seen this go up to 7 files and 3 G Bytes.  And I do not have a lot running.  Free memory is usually pretty low as reported by top, a few hundred MBytes.  I have 4 G of RAM.  Unlike Snow Leopard, these swapfiles never go away even after quitting applications.  Applications were slow to launch as swapfiles were being written to or read from.  I think Mountain Lion has a serious virtual memory problem.

  • etresoft Level 7 Level 7

    Nathan Goldshlag wrote:

     

    Well I *am* seeing a slowdown.

    The cause is not related to virtual memory. The longer you persist in thinking that it is, the longer you will suffer from your slowdown.

Previous 1 2 3 Next