Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I thought that I understood how MacOSX manages memory, but recently I’ve become baffled by its performance. Here is the situation:

  1. I have a brand new Core i7 system with 8GB of physical memory running MacOSX 10.6.7. There are a few Apps running regularly taking up some of the memory—Safari, Mail, Xcode, Terminal, etc.
  2. I need to run three 64-bit processes in parallel, each of which uses about 2000M of real memory.
  3. Although the wired memory stays below 1000M (i.e. I have over 7000M available for processes), I see heavy paging activity leading to very bad performance from the three memory-intensive processes that I launched.
  4. Apparently, I am not running out of available RAM, as the reported inactive memory stays around 2500M and the active memory doesn’t rise above 5000M.

Can anyone give me a clue as to why MacOSX does not release the inactive memory for the processes that need it, instead resorting to paging? Also, is there any proper way to influence the memory management by the system?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

I have found, on my machine, that Mac OS X is a little slow to page the right things out.

Whenever doing anything particularly memory hungry, I will often quit a few applications to help it out. Safari is a huge memory hog if it has been running for a while and is top of the list of applications to quit. In my case this was when I tried to run VMWare Fusion without quite enough actual RAM.

You probably know this but here are a couple of links to Apple documentation which describe memory usage and virtual memory on OS X:

http://support.apple.com/kb/ht1342

http://developer.apple.com/library/mac/#documentation/Performance/Conceptual/ManagingMemory/Articles/AboutMemory.html

Here is the explanation that is given: The inactive list contains pages that are currently resident in physical memory but have not been accessed recently. It's hard to get an exact definition of what this means but is seems to include a file system cache as well as actual inactive memory.

Inactive memory is probably a difficult thing to handle on an interactive GUI driven OS where a user may choose to switch to any running application at any time and providing responsiveness in this sort of situation is important.... but the flipside of that is that in a situation like yours the OS doesn't quite know what the right thing to do is.

It is possible to purge (some of) the inactive memory by using the purge command. This may need to be installed by installing the CHUD tools but you may already have that installed. I haven't tried using the purge command so YMMV...

I've rambled on a bit and may or may not have answered your question. After writing all this out, I found another question on this site which much of the same info that might also help.

share|improve this answer
    
Thanks! The purge command is exactly what I was looking for. I had found the support articles in Apple’s KB, but they weren’t particularly useful. –  Ventzi Zhechev Apr 6 '11 at 7:40
add comment

MacOS does release the inactive memory, but only if it really needs to. That "inactive memory" may actually be memory that the kernel believes to be a candidate for paging out-- but it hasn't decided yet, pending more time passing without the inactive memory being referenced (instead, it's focusing on paging out the memory that really is less likely to be used again soon). In such a case, "purging" the inactive memory will actually cause your performance to suffer (since those frequently used pages would have to be read back in from disk before your program can continue execution).

purge is useful for developers to simulate the start-up conditions of an application-- e.g., to see how long it takes to get an application running the first time after a boot or a long hiatus. For the typical user, purge isn't very useful (and will actually cause temporary performance degradation).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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