Wired Memory vs. Active Memory in OS X

13

6

I'm having trouble understanding the difference between Wired Memory and Active Memory in OS X.

Do not talk about the four types of memory (don't talk about free or inactive memory, because I already know what these are). Just compare and contrast wired memory to active memory so that I can understand those two better.

tony_sid

Posted 2011-07-03T07:38:02.487

Reputation: 11 651

Answers

29

Gentle reminder: To provide a better answer for the rest of the community, please don’t say something like “Do not talk about the four types of memory”.  Even if you know it well, there may be a thousand and one citizens of the Internet arriving here hoping for a collateral answer. :)

“Paging” is the accurate term for the following action. “Swapping” is used colloquially for “paging”, quite interchangeably these days, though. “Swapping” originally referred to the moving of a program’s memory space completely onto “secondary storage” (as opposed to “main storage”, which is an archaic term for... RAM, in a way). The boundary between paging and swapping is considerably blurred by Windows and Unix systems calling the paging space swaps.

And then, one must know about paging in order to understand the concept of active, wired and inactive memory. Paging means that the memory page is moved out of random access memory (i.e., the RAM) and onto the hard disk or other secondary storage device. This allows the running application to request more memory than the total amount of system RAM available.

Note that although paging out means a huge performance penalty to access that particular bit of information again, paging can occur in two different cases: (Quoting myself: Disadvantages of not having a swap partition)

  1. When there is not ENOUGH memory for all applications – in the case where this happens to a system without swap space, it will cause a failure to allocate memory for new applications requesting new memory pages – and this usually results in termination of the program.
  2. When some memory pages (memory is divided into “pages”) is used some time ago, but is no longer used now, it would be transferred to the swap file and the remaining memory can be used to do something else which could be more useful (e.g., even caching!) – when this happens in a system without swap space, this will result in idle pages staying in memory. This is nothing too serious though, as we have a pretty large amount of memory these days.

The four types of memory are classified as follows:

  • Wired: Used by an application that claims that the chunk of allocated memory must stay physically in RAM, and not be swapped onto disk, no matter whether it is recently used or not, i.e., another application may NOT request that particular chunk of memory. Examples are part of the memory utilized by the system, and that used by virtual machines.

  • Active & Inactive: These are memory used usually by user-mode applications, in which they are swappable onto disks. “Active” means that it was recently used, and “Inactive” means that it was not recently used. The operating system thus would swap out inactive pages first, and then active pages later if necessary.

  • Free memory: Memory that isn’t used. This is used for other purposes such as caching of the hard disk.

If your question is, “In a dire situation where memory is inadequate, in what order would the system try to allocate memory to a new application?”, then the sequence would be to allocate

free memory → inactive memory → active memory

In a sense, even recently used memory could be paged.  The “wired” part is what would not be paged out at all costs.

In modern systems, though, it is rather unlikely that active memory gets paged out as we have plenty of RAM available.

bubu

Posted 2011-07-03T07:38:02.487

Reputation: 9 283

1@tony_sid an old discussion but what you have heard is correct. As mentioned on Apple support "However, if you open Mail before its Inactive memory is used by a different application, Mail will open quicker because its Inactive memory is converted to Active memory, instead of loading it from the slower drive." – Gaurav – 2014-09-05T04:47:12.050

This optimization appears to be useful for desktop applications. Such pages of inactive memory should not be swapped to disk because it is in a way freed. – bubu – 2015-01-03T04:00:51.413

"This is nothing too serious though, as we have pretty large amount of memory these days..." The important question to ask, though, is could this memory be used in better ways? There are lots of times where caching can be done that would speed up programs. Having to re-read from disk at the application level because ram isn't available for caching isn't really any different than letting the OS swap. – xaxxon – 2016-09-10T13:50:53.147

Now you made this question more complicated than it had to be by talking about the other types of memory. So now I have to ask about active vs. inactive memory. I heard that inactive memory is actually free memory. What's that about. Is active memory also free memory? Compare and contrast active memory to inactive memory. – tony_sid – 2011-07-03T07:53:16.200

See edits - inactive memory of course is not free memory, if it was, then there won't be such a term. You could ask, could inactive memory be allocated by a new application, the answer is then a yes - it can, but it would result in the current memory page being swapped out onto harddisk. – bubu – 2011-07-03T07:59:25.807

1I heard that inactive memory is simply cache in case a program that was closed is started up again. If that's true then why does it need to be put onto the disk? – tony_sid – 2011-07-04T01:12:16.340

1You heard something wrong. Closed application will have its memory freed unless something is seriously wrong with the memory architecture. – bubu – 2011-07-04T02:38:00.487

You're talking about paging, not swapping. Swapping is something else, that most modern operating systems don't do. – JdeBP – 2011-07-04T11:48:40.063

Edited. See above. – bubu – 2011-07-05T00:06:51.947

2fantastic answer! +1 – posdef – 2013-03-25T10:24:52.547