6

My Mac seems to be using a ridiculous amount of memory when close to nothing is running. Immediately after restarting my computer, and only starting up a terminal and the activity monitor.

How could close to 5GB of RAM be being used when only two processes are running and memory use according to the “Activity Monitor” and htop is closer to 1GB? Any help or insight would be greatly appreciated.

htop displays this:

enter image description here

And the “Activity Monitor” displays this:

enter image description here

  • 3
    It’s nice how you conveniently cropped the actual information (to the right of the Memory Pressure gauge) from your image. ;) – Daniel B Mar 4 '15 at 20:49
  • 1
    What do you mean by this, “…when only two processes are running…” since all of your evidence shows much more than 2 processes running. – JakeGould Mar 4 '15 at 20:57
  • possible duplicate of Something is using up memory in OSX – JakeGould Mar 4 '15 at 21:01
  • Sorry! I was trying to crop out my name. I'll add it. Thanks so much for pointing that out. – user1231120 Mar 4 '15 at 21:04
  • No point me posting an answer, as Jake's covered it well, but just to point out that the new paradigm is 'unused memory is wasted memory'. Forget all the old ideas of 'must keep some free RAM'. If your swap used &/or compressed memory is zero, nothing is amiss. – Tetsujin Mar 5 '15 at 18:51
17

This is pretty easy to explain. Let’s look at a screenshot of “Activity Monitor” taken from my Mac OS X 10.9.5 system just now:

enter image description here

With that as a reference, let’s do some math based on the items on the lower right-hand side of that screenshot:

  • App Memory: 1.59GB
  • File Cache: 1.32GB
  • Wired Memory: 1.30GB

Add those numbers up and the total is: 4.21GB which exactly matches the value of Memory Used which is 4.21GB.

So what is the difference between app memory, file cache and wired memory? All of this is very clearly answered in Apple’s own support articles entitled, “Use Activity Monitor to read system memory and determine how much RAM is being used” which is for Mac OS X 10.8.5 and earlier or this article “How to use Activity Monitor” which is for Mac OS X 10.9 and higher. And here are the pertinent definitions from the later article since—based on your screenshots—that you are using Mac OS X 10.9 or higher:

  • App Memory: The total amount of memory currently used by apps and their processes.
  • File Cache: Memory that was recently used by applications and is available for use by other applications. For example, if you've been using Mail and then quit Mail, the RAM that Mail was using becomes part of the file cache, which then becomes available to other apps. If you open Mail again before its file cache memory is used (overwritten) by another app, Mail opens more quickly because its file cache is converted back to app memory instead of loading all of its contents from your startup drive.
  • Wired Memory: Memory that can’t be compressed or paged out to your startup drive, so it must stay in RAM. The memory used by a process can’t be borrowed by other processes. The amount of wired memory used by an app is determined by the app's programmer.

Now looking at those definitions, it seems like the biggest user of “inactive” RAM is actually the file cache RAM area. Since it is a cache, it can be overwritten/reallocated right away if needed by the system. But since it is indeed a cache, if you relaunch an application that previously used that cached memory, that application will start up faster.

So knowing that, you can safely assume that the 1.32GB of memory used by the file cache can really just be considered “free” memory since the system will just grab it and use it when it can. And—of course—it has the added benefit of speeding up the launch/use of past applications that have things saved to that file cache if they are launched or used again.

Also, note that running graph in the lower center of the “Activity Monitor” called “Memory Pressure.” As Apple describes it:

The Memory Pressure graph helps illustrate the availability of memory resources.

Which is all to say that the “Memory Pressure” graph is an attempt by Apple to help visualize the relative complexity of memory management on modern Mac OS X systems since—as you can see—deciphering memory usage by just staring at raw numbers can be confusing at times.

  • 1
    Thank you! This is very clear. I must have a lot of background apps that are starting up without me starting them. I'd vote you up but apparently I need more reputation to. – user1231120 Mar 4 '15 at 21:32
  • @user1231120 Maybe you have background apps running, but note how I have 16GB of RAM but still have around the same amount of memory “used” as you do. I believe that Mac OS X just generally needs about 4GB or RAM in someway available to operate whether you know it or not. – JakeGould Mar 4 '15 at 21:55
1

Note that memory "usage" is actually rather hard to estimate. There is a very enlightening post about memory usage in Android over at Stack Overflow; although there are clearly differences between Mac OS X and the modified Linux kernel used in Android, there are enough similarities that it’s still relevant.

Taking into account shared memory, per-process memory, and virtual memory leads to a confusing picture of what is “in” memory and what is not. “Activity Monitor” and htop simply use a different estimate. This isn’t worrying, and the amount of used memory in your case—5GB—is pretty normal considering you have 8GB of memory installed.

  • 1
    Thanks for the response! Even after reading the article, I'm still rather confused as to what could be using those extra 4 GB of memory. My coworker and I both turned on our computers (which are the exact same model) and immediately opened the activity monitor. Mine looked as above and his looked very similar in terms of memory usage for individual processes, but was only using slightly under one of his 8 GB of RAM. What could be causing my computer to have almost 4 GB of unaccounted for RAM at startup whereas his does not? – user1231120 Mar 4 '15 at 20:57
  • It's also worth noting that I discovered this discrepancy when a test that requires a lot of memory was hanging on my computer and not his. If we both turn on our hardware identical computers and immediately run this testing suite, mine will hang and htop will show maxed out RAM, while his will run with htop showing memory to spare. – user1231120 Mar 4 '15 at 21:01
  • @user1231120 Why are you the one complaining though? His system is the one that's wasting memory, not yours. If you're thinking "I want memory free now so I can use it later", that's nonsense. You can use it now and use it later. There's no tradeoff here. Using memory is a pure win. – David Schwartz Mar 6 '15 at 5:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.