18

I have a late 2013 MacBook Pro 13" with 8 GB of memory. Lately my MacBook Pro uses swap memory, when it has enough free memory. Is this normal and can I do something about it? Also when I only have safari and let's say Xcode open it uses 99% of the RAM. Is this normal behavior?

enter image description here

  • @Mark I'm going to keep this open - the other question doesn't focus on swap as a symptom. I think this is slightly different enough to warrant some extra answers that might not fit on the linked question. – bmike Jun 10 '15 at 16:49
17

This is normal behavior. You are not experiencing any memory issues in your screenshot above. What I suspect is happening is that OS X is creating some placeholder of sorts to enable swap memory, rather than actually using swap memory here. I have never seen a zero in the swap memory section, unless I have just restarted and open the Activity Monitor window fresh, and even then, I rarely see zero.

With Mavericks and Yosemite, the way the OS uses memory changed a bit. Essentially, the OS takes all the memory, and then manages it out as needed. So, our traditional way of looking at the memory report in Activity Monitor is not really valid. Due to this, Mavericks added the 'Memory Pressure' gauge, to give you an idea of when you have a limitation caused by memory. In your screenshot, you have a green memory pressure. For more see this answer.

Ars Technica has a nice description of this 'memory compression' in their Mavericks review:

http://arstechnica.com/apple/2013/10/os-x-10-9/17/

  • Well said. 256 KB of swap is a rounding error and could even just be a placeholder to ensure that the swap file exists and is open. Should the system run out of file handles or resources later having that file created and open might allow greater stability and recovery from edge cases. – bmike Jun 10 '15 at 16:52
2

According to what I can understand from your screenshot (I don't know your language), you're only using 256KB of swap space, which is nothing. I wouln't worry unless your memory pressure went up

  • Right now its indeed 256KB but sometimes it uses 120mb or more if there is some free memory. – Bas Jun 10 '15 at 10:56
  • I'd say this is normal, my Mac has been up for almost 6 days now, and I have ~200MB of swap being used, with 16GB of RAM installed and 24% memory pressure (green) – Brethil Jun 10 '15 at 12:21
  • @Bas Ask a follow on question when you find swap growing. You can run vm_stat 60 or even 300 for the interval and then see what the paging looks like and upload a second activity monitor snap showing the paging case. – bmike Jun 10 '15 at 16:53
0

You would need to be monitoring the memory and swap usage as the swap file was created to have a chance to understand why the swap was created. Based on what you describe in text and in the screen shot, I see nothing that is concerning.

As to why swap was created when you assume you had free RAM. The OS can move to swap based on predictive measures. For example, maybe you started up Photoshop which had several large image files automatically reopen from a prior session. The OS could see that there was suddenly a huge new demand on RAM, and moved some unused RAM content to swap in advanced of an expected need.

Or your backup program briefly ran in the background, and did a huge number of file checksums and comparisons and created large RAM based data structures, pushing other content to swap. Then the backup program released its RAM and went back to sleep.

Mac OS X (and most modern OS: Windows, Linux, etc) are very intelligent about automatically using Cache, Swap, memory compression and other techniques to keep the system running as fast as possible. I really would not be worrying about this unless you see that the Activity Monitor is reporting that Memory Pressure is in the Yellow or Red zone.

I currently have a 2010 13" MacBook Pro that has 16GB of RAM. I do lots of work that is heavy on RAM usages. (Web Development, data mining, running many heavy duty apps at the same time.) Even with 16GB I sometimes hit the Yellow zone for memory pressure. But I have to say this is seldom an issue because Mac OS X is very good about allocating resources as needed.

While I need the 16GB of RAM for my work, you should know that such an upgrade is not without negatives. The extra RAM does significantly reduce battery life both in active usage and in sleep.

-1

Your Mac runs on Unix ( certified Single Unix Specification 2003 ), and that OS has been around for 40+ years. Core components (like memory management) are written, updated, debugged and polished by people who are definitive experts in the field. Apple, with more cash on hand than the US Treasury, can afford to hire the absolute best.

So, unless you have at least a PhD in theoretical computer science, and wrote your thesis on kernel-level process and memory management, stop worrying about the memory management. I have 24Gb in my desktop and it still uses swap. This concerns me not at all.

  • 3
    You are right, but this doesn't answer my question. I'm not saying the people that made the OS don't know what they are doing. My question was if this was normal behavior and I'm interested in why it's doing this. Because it doesn't make sense to me to use SWAP if there still is some memory available.. – Bas Jun 10 '15 at 13:47
  • My point is that anything that happens under the hood is normal. Unless your disk is full due to absolutely staggering amounts of swap you should consider the reason to be because the memory manager decided it needed to. – paul Jun 10 '15 at 14:28
  • 1
    This is almost entirely false. macOS has no original Unix code in it, it used some *BSD and Mach parts and might be POSIX certified. The VM Page management however is almost completely Apples code and they added lots of instability in the last releases by modifying it like adding vm_compression. Also theoretical computer science does not concern itself with these very practical issues. They suck at OS development lately. – sleeplessnerd Feb 20 '18 at 15:19
  • Ridiculous answer. I'm sure they have experts building the whole product yet mistakes happen and they get things wrong quite a lot. – chrismacp May 3 at 11:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .