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

Aug 1, 2012 12:31 PM in response to megagram

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.

Aug 2, 2012 5:37 PM in response to megagram

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.

Aug 3, 2012 4:50 AM in response to David A. Gatwood

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.

Aug 3, 2012 7:36 AM in response to megagram

I'm constantly checking Activity Monitor and "Free RAM" is always around 8GB or more

Meaningless information.


An application could spike its memory usage, then go away giving back all the memory. You could have been running a backup which was filling the memory with cached data, while another app(s) was in need of memory then things quieted down.


You cannot be working AND watching Activity Monitor full time, and Activity Monitor is ONLY showing you free memory for the moment you are looking at it.


If you want to track free memory over time, then start am Applications -> Utilities -> Terminal session and run a command such as:


vm_stat 60


which will watch the VM statistics and report them every 60 seconds (change the time interval if you like, but make sure your Terminal scroll back is sufficient (and if it is set to "available memory" keep in mind that if you allow this to run long enough, Terminal will suck up all your RAM 🙂 ).


Then if vm_stat never reports your free space AND inactive space as going low together, then you might have an issue.


HOWEVER, if you have an app that uses anonymous memory mapped pages as a way to communicate between processes (such as a browser that uses separate processes for each TAB, but keeps the pages and images in a common cache of mapped memory, then this anonymous memory mapped area is frequently backed by the /var/vm/pagesfiles.


There are a host of reasons why Mac OS X might allocate /var/vm/pagefiles, but never use them or use them briefly.

Aug 3, 2012 9:41 AM in response to BobHarris

Thanks Bob,


You know what I think I narrowed it down. Everytime I wake from sleep, there is a huge delay and I've been troubleshooting that issue as well. I've also noted that my memory is fine and there is no swap used until right after I wake from sleep.


So, I've been waching processes after sleep and my fontworker process was spiking and hanging my computer. I've disabled all third-party fonts and it's gone away and the swap issues have been resolved as well. So I guess it was spiking CPU as well as using a HUGE amount of memory as well, hence why it was casuing all the swap files to be created.


Thanks for the insight.

Aug 3, 2012 9:44 AM in response to etresoft

If you don't know the real answer, please don't waste our time with speculation that isn't going to help any of us.


And all "Swap used" means is the amount of hard disk space that is used up by the various swap files in /var/vm. Quite simple.


These files only get created when physical RAM is exhausted, which is why my concern is there in the first place, with 16GB of RAM and a light workload it made no sense to see these files.


But, as I"ve mentioned in another reply, it was a font issue causing the fontworker process to consume lots of memory.


But seriously, I think you need to refresh what you think you know about virtual memory before coming into these forums and claiming a bunch of nonsense.

Aug 3, 2012 10:50 AM in response to megagram

megagram wrote:


And all "Swap used" means is the amount of hard disk space that is used up by the various swap files in /var/vm. Quite simple.

I actually went out of my way to track down the answer to a valid question that has been asked before. I made a point to avoid giving you such a simplistic answer.


But, as I"ve mentioned in another reply, it was a font issue causing the fontworker process to consume lots of memory.


But seriously, I think you need to refresh what you think you know about virtual memory before coming into these forums and claiming a bunch of nonsense.

And as I mentioned earlier, virtual memory is Mountain Lion is highly optimized. Anyone who dwells on it looking for a problem where there is none is going to accomplish nothing but waste their time. Had you not been so concerned about perfectly normal readings in Acitivity Monitor, you might have found the problem in less than four days.


In the future, if you have a specific problem like a hanging system right after waking from sleep, do us all a favour and mention that at some point. 🙂

Aug 3, 2012 11:16 AM in response to megagram

megagram wrote:


I did mention that I had a problem with hanging right after waking from sleep. I guess you weren't paying attention.


That was in your 6th post, a reply to my question, in the first 5 posts you did not mention it, I think you are being a bit too dismissive of etre's attempts to help with a problem vaguely described. Happy that you found the answer to the 'hanging' issue.

Aug 3, 2012 11:54 AM in response to Csound1

True. My point is his attempts at helping were not helpful at all given the fact that almost everything he said about VM was wrong.


I had no idea what the problem was. There is a problem when you have 3GB+ of swapfiles on a machine with 16GB of RAM and a light workload.


He dismissed my issue by stating that the OS was optimized and I shouldn't worry about it along with many other inaccurate statements.


It wasn't until further troubleshooting/diagnosis that I found the odd issue being related to waking from sleep and from there, the fontworker process. This doesn't discount my issue or the problem I had, it was just an extension of troubleshooting.


So, for those checking it, the fontworker process was spiking CPU and RAM usage causing all of the swap space to be created no the HD momentarily. Hence the "Swap used" stats and swapfiles in /var/vm being created. I fixed it by removing third party fonts.


Had I listened to etre I would not have solved my issue.

Aug 3, 2012 12:36 PM in response to megagram

megagram wrote:


True. My point is his attempts at helping were not helpful at all given the fact that almost everything he said about VM was wrong.

I will not say anything here on Apple Support Communities unless I know it is true. If I need to guess or speculate to pacify someone who won't take an answer (as in this case), I will qualify my answer (as I did in this case).


I had no idea what the problem was. There is a problem when you have 3GB+ of swapfiles on a machine with 16GB of RAM and a light workload.

Until a couple of hours ago, you had not indicated that there was any problem with your system. You were asking a question about virtual memory. I told you to ignore virtual memory because "If you are having problems, the cause is elsewhere" - as it was. If you have bad fonts and some process running out of control and exhausting 16 GB of RAM, you do not have a "light workload". Obviously you weren't "constantly checking Activity Monitor" either. I should have noticed a statement that suspicious. Oh wait, I did.


Had I listened to etre I would not have solved my issue.

To redundantly repeat myself - if you have an issue - say so. You can't post a screenshot from Activity Monitor with values on it that are identicial to 2 million other machines and expect anyone to get worked up over it.

Aug 3, 2012 12:41 PM in response to etresoft

etresoft, you continue to misinform people here and claim there is not virtual memory problem. I had no font problem like megagram, yet relatively quickly got huge swapfiles and the system was unresponsive and slow to launch applications. When I said the disk accesses are relatively slow you just poo-pooed it. Sorry but the reason things were slow as writing to these swapfiles. This is how virtual memory works - when you run out of physical memory stuff gets written to disk so that applications can access large memory spaces. In my case I was not running a lot of stuff.

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.