You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Over 3GB of swap files with 16GB of RAM?

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

Posted on Jul 31, 2012 6:44 PM

Reply
Question marked as Top-ranking reply

Posted on Aug 2, 2012 4:42 PM

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.

User uploaded file

73 replies
Question marked as Top-ranking reply

Aug 2, 2012 4:42 PM in response to Csound1

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.

User uploaded file

Aug 14, 2012 4:55 AM in response to megagram

I've had a similar problem, I didn't know I could look up swap space in activity monitor, but I whipped out Grand Perspective, and all those green blocks in the upper right are 1gb swap files. All created in the space of about 2 mins. The system slowed right down, and then I had to start force quitting apps because there was 0mb left on the hard drive, before restarting. They're now all gone on a restart. Definitely a bug somewhere!

User uploaded file

Aug 19, 2012 6:02 PM in response to megagram

So sad! But at least we clearly have the same issue. I did file a bug report with apple about the issue, so we will see.


Just a detail on hibernatemode... 3 is, I believe, a sort of "smartsleep" mode where it writes out memory and goes into normal sleep immediately (RAM still powered), but after a set time it goes into deep sleep—hibernation, if you have it unplugged. If you look at pmset -g in Terminal, you'll see all your power-related settings:


User uploaded file


You can see above, I am in hibernatemode 1 for testing (so I don't have to wait). If you are in hibernatemode 3, at least on a MacBook Pro Retina or other recent MB(P/A) laptop, you should also see a field called standbydelay. This is the time (in seconds) that your machine will stay asleep on battery power before transitioning into full hibernation. You can check this out yourself when you're in hibernatemode 3: look at your output from the above command, and note the time next to standbydelay. For starters, put your machine to sleep for a short while and wake it up. You will see it wakes instantly, especially if you have a Macbook Pro Retina 😉. Now, put it to sleep again and wait until after the standbydelay has passed. You'll notice that it takes much longer to wake up, because it's reading your RAM from the sleepimage, because, again, it powered the RAM down and fully hibernated. those of us with tons of RAM will notice this doubly, literally, because it takes 2x as long to read 16GB from an SSD as it does to read 8GB.


Anyway, sorry if I'm being too wordy—when you go to hibernatemode 0 you will only sleep, and when your battery dies, it will be essentially the same as if your computer crashed... you'll have to reboot. Considering that only takes a few seconds longer than waking from hibernation (on the rare occasions it does happen), and with most apps now saving their state across reboots anyway, it's not that big of a deal. You will likely notice, though, that if you leave your computer asleep in hibernatemode 0 and unplugged for a long time, when you wake up again, the battery will be drained a lot more. If you're on the road and looking to conserve battery to the maximum, this may be a major consideration. For me, not that big of a deal. YMMV, right?


Hopefully this is the temporary fix for us. I've only been trying it this afternoon, so I am not 100% on it being a sure workaround. But here's hoping.


Cheers!

Aug 11, 2012 10:59 AM in response to etresoft

etresoft wrote:


Lion runs with a 32-bit kernel by default

You gotta stop spewing all this irrelevant, inaccruate information, man. Lion runs with either a 32-bit or 64-bit kernel depending on your hardware! http://support.apple.com/kb/HT3773


Also, it is completely irrelevant whether the kernel is running 32-bit or 64-bit mode. 64-bit applications can still run on top of a 32-bit kernel! Therefore, on 64-bit hardware, running a 32-bit kernel, Photoshop would still install and run as a 64-bit application and would have all of the memory access it needs (ie 4GB+ compared to 32-bit).


I'm going to start a new job I think, and it's going to be correcting all the wrong things you say. 18,000 posts? Whew!

Aug 11, 2012 12:03 PM in response to megagram

megagram wrote:


Also, it is completely irrelevant whether the kernel is running 32-bit or 64-bit mode. 64-bit applications can still run on top of a 32-bit kernel! Therefore, on 64-bit hardware, running a 32-bit kernel, Photoshop would still install and run as a 64-bit application and would have all of the memory access it needs (ie 4GB+ compared to 32-bit).


I'm going to start a new job I think, and it's going to be correcting all the wrong things you say. 18,000 posts? Whew!

Be my guest 🙂. The 18,000 figure does not represent posts. It represents points awarded by other members of Apple Support Communities for helpful and solved answers. There used to be an indicator of how many posts a person had, but that was lost in the last upgrade. A person could theoretically get 18,000 points in only 1,800 replies.


If you read that tutorial closely, you'll see that there is, in fact, no "correct" category of answers at all - only "helpful" and "solved". This isn't a community for people to spout off on how much they know, it is for people to learn more about their Apple products and get help with problems. In a venue like this, there is no way to have perfect knowledge of someone else's machine. Many suggestions are wrong but they help lead people to learn more and maybe figure out the problem.


Consider what would have happened if everyone in this thread had give you the standard "me too" answer of - "Yeah, Mountain Lion is way slower than Lion and especially Snow Leopard. That is a virtual memory bug." You would have given us praise and helpful/solved points instead of insults. You would be putting up with this problem for years, waiting for an update that never came. Instead, we challenged your assumptions and made you dig deeper and find the actual problem.


You're welcome.

Aug 11, 2012 1:49 PM in response to megagram

megagram wrote:


I just shudder to think how many of those people who marked one of your posts as "Helpful" (as I did in the beginning of this thread) because it seemed like it would provide the correct answer.


What good does spouting off knowledge do for anyone? In some situations, I make a point to avoid giving someone the "correct" answer. I would rather give them a hint about where to find the answer so that they learn more about the system, as you have done.


Until of course I asked for clarification and a source and you couldn't back it up--it was just some weird hunch that you had developed.


I have developed many weird hunches over the years. In this case, I tried again to track down where I developed this particular "hunch" and, miraculously, found it. The "sophisticated fakery" I was talking about is memory overcommit. This mailing lists post looks familiar. It may be the source you were looking for. This post may lead one to more details about modern memory management. Specifics about MacOS X are hard to come by. MacOS X Internals is the best reference but is quite old. If you want to know more, you will have to enroll in a graduate-level computer science program with a good research program in operating systems. Virtual memory management is not an area where end-users need to be concerned. Anyone experiencing problems should look elsewhere.


Wish I could take back the "helpful" tag. Oh well.


Perhaps you could complain to the moderators in Using Apple Support Communities.

Aug 19, 2012 4:48 PM in response to megagram

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.

Aug 30, 2012 3:16 AM in response to nalundgaard

I had the same issue on my MBPr (on my 3rd replacement for screen issues, but that's another story)

Huge swap files without any pageouts and lots of ram free. My setup was MBPr 512gb, 16gb on ML.


Did some research and it turns out this is definitely attributed to power management and specifically standby mode.


Sleep mode is when everything powers down but RAM is preserved by keeping its power on.

Standby mode is when the contents of the RAM are written to the disk and it too powers down bringing the whole system in a minimum power consumption mode.


Only the new macs have a standby mode.


http://support.apple.com/kb/HT4392


How this works:

after the mac has been in sleep for 4200 seconds (default value) or 70 mins,

all the contents of the RAM (which was still drawing power) are written to the disk

then the RAM is powered down as well.


This is what creates the swap file!

The size of the swap files depends on the amount of RAM that was being used when switching from sleep to standby mode.


Upon waking, the swap file is passed back from the disk to the RAM. That is why there is a short delay (5-20 sec, YMMV) for the mac to wake.


this delay is avoided if you wake your mac before it has a chance to enter stanby (<70 mins)


How to solve it:


It has been suggested to change hibernation mode. This works but it has other RISKS!


there are three hibernation or sleep modes (for our purposes hibernation=sleep here)


Mode=0

default for desktop macs: RAM always stays powered. it is not written to disk and if you lose power you lose what was stored in RAM


Mode=3

default for laptops: RAM stays powered but is also written to disk. If power is lost the contents of RAM are retrieved from disk and no data is lost.

This is what all the laptops have been using until the introduction of standby mode with MB air and MBPr.


Mode=25

RAM is written to disk and powered down. when waking data is restored from disk.


see: https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages /man1/pmset.1.html


If you change to hibernate mode=0 or 1 (1 is not supported by apple) when your battery dies you will lose what was in the RAM.


Standby mode is essentially a mix of mode=3 and mode=25 with a set delay between them.


The bottom line:


If you want to get rid of the swap files DO NOT change your hibernate mode. Just disable the standby mode.


What you get: your mac will not dreate the swap file. It will wake instantly no matter how long it has been in sleep for. If your battery dies while in sleep mode, you will not lose any data as they are ssaved to disk as well.

The only downside is that without standby mode, your battery will drain faster when the mac is sleeping and not connected to power. (that said it should last a couple days in sleep mode)

What apple advertises as 30 day standby mode is the actual standby mode not the sleep mode.

If you are ok with that, (this has been the bahaviour of all macs until the MBPr and the new Airs that support standby) go ahead and disable standby mode.


but DO NOT change your hibernate mode.


to disable standby:


type in terminal:


sudo pmset -a standby 0


it will ask for your password

type it (even though nothing will appear on screen for security reasons) and hit enter


DONE!


BONUS the best of three worlds...

you can instead change the time it takes for the mac to enter standby mode.


IMHO this is the best solution.


make your mac go to standby mode after 6 or so hours of sleeping. that way you get all the benefits plus the battery savings and you only have to wait longer to wake if you havent used it in over 6 hours. This of course means that if you wake it after 6 hours the huge swap files will be there again.


if that sounds good to you change the defaut value from 4200 to what suits you. (6 hours would be 21600)


to do that:


sudo pmset -a standbydelay 21600


That's it! Hope this helped

Sorry for the long post. Had to make sure it is all clear.

Aug 31, 2012 4:05 PM in response to MacJonny

Yes, that's what I've done as well (see my previous post). Disabling standby keeps the swapfile empty and also makes your laptop wake up much faster. As I mentioned, it does make your battery drain faster while sleeping. That doesn't bothered me. I've been using hibernatemode 0 for over a week now (since that last post), with an uptime of 8 days. My swap is still empty.


So, this resolves the issue. I still think the paging out without incrementing pageout count must be a bug, but I guess I don't know. Maybe it is saving some other volatile state information there, e.g. the GPU RAM or something. The pageout amount seems awfully high for that though (GPU only has 1GB RAM on my mac), and I would think it ought to clear out after waking if it were intentional.

Jun 23, 2013 9:11 AM in response to chef098

chef098 wrote:


So I have been reading over this thread and I think I may have this no pages outs occurring. I have a 4gb mac pro (Late 2012) with ML. I dont think that such a system should almost be unusable. These stats are after 72 hours of no full system restart. Just going into sleep mode.User uploaded file

You need more Ram.

Aug 1, 2012 5:49 AM in response to megagram

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.

Aug 1, 2012 10:06 AM in response to etresoft

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.

Aug 1, 2012 10:36 AM in response to Csound1

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.

Over 3GB of swap files with 16GB of RAM?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.