Wired, Active, Inactive, and Free physical memory (RAM)

finally found a good explanation for the Mac specific terms Wired, Active, Inactive, and Free for the physical memory (RAM). You can digg it up here.

Just in short:

Wired memory is used by the OS and is pretty much untouchable. Another application can’t “borrow” wired memory.

Active memory is what is currently in use by running applications. Note that thanks to the splendors of virtual memory, all of the memory needed by an application isn’t necessarily contained here. If you look at a running process in the Activity Monitor list, you’ll see a column for Real and a column for Virtual Memory. Since we are talking about the amount of RAM in use, we won’t worry about virtual memory for the moment. If there is no inactive, or free memory, active memory can be used by other applications, but this causes the OS to write the current state of the active memory being traded to its owner’s virtual memory pages on disk before granting the memory to another application.

Inactive memory is memory that has recently been used by an application that is no longer running. OSX keeps track of what this is and what it belonged to because of the idea of temporal locality, the idea being that if you opened an application you are somewhat likely to do so again and if the memory is still labeled, the application can start very quickly. In the absence of sufficient free memory, inactive memory will be reclaimed by another running application that needs memory.

Free memory is just that, free. Nothing has a claim on it, and it’s up for grabs for any application that needs it.

As you can see from my screen-shot image above, I tend to run with around 100-200 Mb free, between 150 and 300 Mb wired, and the rest split between active and inactive. What does this memory labeling have to do with how fast or slow the machine runs? Simple. When you log in, OSX claims the memory it needs to do all of its chores. This is wired. Other applications claim a smallish chunk of active memory as they are opened. Most applications that need to keep track of any kind of history or user data gradually use up more memory the longer they are open. Every now and then an application will need to use some part of its memory that it doesn’t use frequently and OSX has to get this from disk and place it in that application’s active memory allocation. All of these things can slow down a system. Also, virtualization applications such as Parallels or VMWare’s Fusion require a large chunk of memory for the virtual machine that gets marked as wired.

Related

Flickr Explore ...

1 comment

Efficient memory management is an important aspect of writing high performance code in Mac OS X code. Tuning your memory usage can reduce both your application’s memory footprint and the amount of CPU time it uses. In order to properly tune your code though, you need to understand something about how Mac OS X manages memory.

Unlike earlier versions of Mac OS, Mac OS X includes a fully-integrated virtual memory system that you cannot turn off. It is always on, providing up to 4 gigabytes of addressable space per 32-bit process and approximately 18 exabytes of addressable space for 64-bit processes. However, few machines have this much dedicated RAM for the entire system, much less for a single process. To compensate for this limitation, the virtual memory system uses hard disk storage to hold data not currently in use. This hard disk storage is sometimes called the “swap” space because of its use as storage for data being swapped in and out of memory.

Note: Unlike most UNIX-based operating systems, Mac OS X does not use a preallocated swap partition for virtual memory. Instead, it uses all of the available space on the machine’s boot partition.