Wednesday, 28 November 2018

macos - Mac OS X using over 4 GB of memory with nothing running


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



Answer



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.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...