100

I'm looking for explanation of memory usage on my machine especially in light of the example in this screenshot below:

Memory Usage

I understand what is Free and Active means
But what are the meanings of Wired and Inactive?

Especially inactive, why does it use so much memory for something that we do not use?

0

7 Answers 7

166

Inactive memory got a horrible rap due to a crappy name. It should have been called something like "make your Mac really fast the second, third, and fourth time it does the same task" memory except that's an awful name, too.

Apple re-wrote the activity monitor when it introduced several new features and added compressed memory, so some of this no longer applies to macOS that don’t show “Inactive Memory” but this still applies to Mac OS X memory management as documented against this version of Activity Monitor: https://support.apple.com/en-us/HT201538

Here's how I explained things to someone new to the concept of virtual memory on OS X:

  • Wired: The system cannot run without this amount of RAM (never swapped)
  • Active: Programs are really using this memory now or in the last few seconds
  • Inactive: Things that programs have read from the slow disk or elsewhere and said they never need again. Engineers know better, you will go back to Facebook in a few minutes or re-launch Word after quitting it. The same things happen again and again on computers.
  • Free: Totally Wasted RAM - the system only needs one or two MB free to cover short term allocation requests. For largest allocations, it simply uses some of the Inactive RAM by allocating it to active/wired and removing the information on what it used to hold.

The problem arises when Free+Inactive is less than roughly 1/3 of the total and then things can really get slow.

Inactive memory is bonus speed / double duty RAM. It serves as free at a moment's notice, but also makes repeated tasks much, much faster if the system guessed correctly and kept something in RAM that you will do again. It's faster than swapped memory since it's already loaded in RAM and accelerates things when the virtual memory system makes good guesses.

When you are wondering if RAM is a problem, rather than looking at each of the 4 categories (5 if you count active swap), you can couple W+A as slowing down a new program/task and F+I as speeding up a new program/task. The more F+I you have, the more new programs you can launch before the RAM needs to rely on swapping to juggle the memory that has been allocated.

You don't really need to know how swap works since I mentioned it above. Basically, when a program is sitting idle and hasn't been used for days (or hours) the system will write that RAM to the hard drive rather than kill the program. This lets the system shuffle and handle all sorts of things relating to memory management and keeps each program from needing to talk amongst themselves to agree who will use less memory when the system runs out.

Here is a real world example of how inactive RAM is used.

  1. Quit all apps and make sure the two Apps we are testing are not set to auto start when you log in
  2. Reboot your Mac
  3. Fire up your Activity Monitor and watch the RAM throughout
  4. Time how long it takes to start Application A (MS Word would be a good choice)
  5. Quit A
  6. Time how long it takes to start Application B (Adobe something would also be good)
  7. Quit B
  8. Time how long the second launch of A takes
  9. Quit A
  10. Time B's second launch.
  11. Time A's start the third time with B running.

You should see dramatic speedups for the second / third launch as the system learns to keep in inactive RAM the things these two apps need to run.


In your case - the total of Wired and Active means that some swapping to disk is likely happening and your Mac isn't as fast as it could be since your inactive RAM isn't large enough to store all the things you might need to reuse. If you have a fast SSD drive, this RAM allocation is OK and instead of starting to slow down once less than 1/2 of your RAM is F+I, you can cut things closer to like 1/4 of the total RAM for F+I before seeing noticeable slowness. These guidelines are general, and you'll want to watch vm_stat 15 or some similar interval to ensure continual and medium volume swapping isn't making your Mac slow.

23
  • 12
    Wow very complete answer for newcomer like me. Thank you very much, very appreciated :)
    – GusDeCooL
    Commented Oct 11, 2012 at 15:22
  • 7
    Yup - I get to answer for everyone - once and for all, people can edit it to make it better and you get your answer. Pretty cool idea for a web site where people can come and ask interesting questions. :-)
    – bmike
    Commented Oct 11, 2012 at 15:23
  • 3
    Wow! Beautiful answer!
    – duci9y
    Commented Oct 11, 2012 at 15:27
  • 3
    I wish they explained it like this in my OS class.
    – styfle
    Commented Oct 16, 2012 at 18:23
  • 2
    @cvsguimaraes purge is not instant; chat.stackexchange.com/transcript/message/12107920#12107920 Commented Nov 10, 2013 at 18:51
6

The number which is the most important in determining if your Mac is getting memory 'stressed' is the 'Page outs' figure. In Activity Monitor in Mavericks this is no longer shown, they now show the information in 'Swap Used:'.

Page outs means the OS has determined there is not enough available RAM to run all the applications & processes which have been requested. What it then does is it 'pages' out to disk parts of memory which it determines are not being actively used. This means RAM memory (fast) is changed to HDD memory (slow). If this is happening a lot because there are a lot of applications running, and the user is going between applications, then there will be a lot of page outs, and page ins.

If you see page outs increasing then you should take action.

2

The problem on my Mac is the "inactive" memory never seems to get purged unless I do a manual purge in the command window. It builds up and builds up until I get a popup window telling me to kill applications. Even after killing all my applications, I still have too much inactive memory to run anything. So, on my Mac running the latest version of Mountain Lion it is NOT true that inactive memory gets reclaimed when the free memory gets low. Either I have an app somewhere that has locked up a chunk of inactive memory that never gets freed, or the iOS has a bug in it. (I have 8GB of physical memory ... that ought to be enough!)

5
  • 2
    I'm with you, Ernie... in Mac OS 10.6 and 10.7 on a MacBook Pro and Mac Pro, inactive memory will creep up, and the OS will start swapping (according to "Page Ins" and "Page Outs") and the system will crawl to a stop. The inactive memory seems to never get reclaimed. I have to use "purge" to reclaim the inactive memory, and get my system active again.
    – Eric
    Commented Jul 31, 2013 at 22:08
  • 2
    Where does this popup window come from? What is the memory situation as reported by vm_stat when it does happen? What makes you so sure that there can be "too much" inactive memory "to run anything"? As far as I'm concerned, this is all hearsay that has no backing in the code that you know, actually runs in the kernel. Commented Oct 23, 2013 at 17:52
  • 2
    Does your memory allocation look anything like what Gus has presented? Here we're talking about a gigabyte wired and a gigabyte and a half active. The inactive / free ration looks fine to me in this situation. Perhaps you would ask a second question detailing the situation you have where things are breaking down?
    – bmike
    Commented Oct 24, 2013 at 18:27
  • @Eric did you ever figure out how to purge to get your inactive memory back?
    – c_idle
    Commented May 20, 2020 at 4:33
  • @Ernie short answer: No. Longer answer: It's been almost 7 years from the original question, and even I (who wait years to upgrade to a new MacOS version) am up to 10.13 and 10.14, neither of which report Inactive memory anymore. I can't recall if I ever resolved the issue back on 10.6 or 10.7. I haven't noticed any similar behavior in 10.13 or 10.14.
    – Eric
    Commented May 20, 2020 at 18:56
1

Thanks to all the posters and commenters, this has been a instructive and useful thread for me. My recent experience might be useful to someone. I use my Mac Mini with OS X10.8.1 and with 16G RAM entirely for prototyping software that will be run elsewhere. I can assure you that I will not "go back to Facebook in a few minutes or re-launch Word after quitting it"--I do that on my macbook instead.

My task was to munge up a large bunch of data, i/o is time consuming, so the notion is to read as large a chunk of data to ram as possible at one swoop, process it there, and then write it back to disk, then repeat the process until done, which takes some hours. What I see is that every time I read in a new chunk of data, the inactive memory jumps--I suppose that the system AI assumes that I might want to use the old chunk again, which I don't--and the free memory drops.

After a few iterations of this process the free memory gets down to a just a few MB, the inactive memory will free up a few more MB, and then eventually after some minutes of quibling back&forth between free and inactive memory, the inactive memory will free up a few GB at once. All is as @bmike describes, and both vm_stat 15 and Activity monitor show 0 page-outs.

Except maybe not quite. Several times things have been moving along swimmingly, I head off to have a coffee or dinner and am not monitoring the process, and what shouldn't happen happens and the process suddenly throws off a boatload of page-outs and slows way down. Stipulate that it's probably my crappy code that's causing the problem but I wish I could turn off the inactive memory just to eliminate that source of variability. Is it broken? I wouldn't say so at all, but I would say that I guess the memory management is not optimized for my use case.

0

Inactive memory used by recently active and quit apps. OS X keeps it reserved in case the user wants to open the program again. In it happens, OS X does not need to relocate memory that accelerates performance speed. If you do not re-open the program, after a while the memory of the inactive will be freed or relocated.(c)

This feature is cool when you have a lot of RAM, but when it's not it's quite annoying. Actually it's all about apple stuff. When you have powerful gadget or Mac everything is cool, but when when you device become older all features slows it.

So u have to use special tricks to manage it.

For inactive memory there is a command purge to free it.

-3

Basically it's broken. Inactive RAM should be "purged" automatically when Free RAM is low. What's the point of holding RAM for previously opened applications hoping that the user will open it again? The fact that Free RAM is low indicates that existing ACTIVE applications might not have enough RAM and is swapping NOW. Keeping GB of RAM for closed applications is just dumb. According to Apple's own description, Inactive RAM should be purged or borrowed automatically when Free RAM is low. This is clearly not the case.

3
  • 3
    Virtual memory systems make large amounts of free RAM a waste. When a program asks for a memory allocation, the kernel makes up more virtual memory and hands it out like candy. Only when a program fills that memory with actual data does the system need to make room in RAM for that operation. That "making room" pulls from free and then inactive memory - and the delay to release inactive memory is immeasurably small. The purge you describe is exactly what happens - just that you imply the system should do the purge work up front when the system is lazy and only does that work if needed.
    – bmike
    Commented Feb 4, 2013 at 18:37
  • @bmike But wouldn't hat mean that when there is no free RAM left and I start a new App, that the inactive RAM portion would decline and active would rise? That is clearly not the case and from my experience the system gets extremely slow whenever there is no more free ram left, despite there being gigabytes of inactive ram. The system seems to prefer swapping disk before it considers reusing inactive ram. Commented Jun 7, 2013 at 13:20
  • 4
    @codingFriend1 Let's be precise - how many pages free in vm_stat do you consider "no more free RAM"? When the Mac is "slow" what are the page in and page out counts for vm_stat 1? Any time I'm watching this on a problem system, I like to have vm_stat 15 running in a terminal window (or logging to the filesystem) so I can know precisely what the paging activity is when deciding if/when I'll tune things like the pager. This example has 100 MB of free RAM, so it's not likely even under paging pressure.
    – bmike
    Commented Jun 7, 2013 at 19:44
-3

Inactive memory in essence, makes opening up formerly closed processes faster. If you find that the Mac OS is taking up too much memory you don't really need like from the dozens of tabs you opened on Safari or Chrome just use the 'purge' command in the Terminal. In OS X Mavericks just use 'sudo purge' instead (you will need to input your password). It shaves off precious seconds when you need to open something up again, but if you want to play a RAM intensive game or open a RAM hungry application I definitely suggest using the purge command.

1
  • 2
    How does this differ from other answers?
    – mmmmmm
    Commented Oct 28, 2013 at 13:38

You must log in to answer this question.

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