Trouble Understanding Inactive Memory in MacOSX
I thought that I understood how MacOSX manages memory, but recently I’ve become baffled by its performance. Here is the situation:
- I have a brand new Core i7 system with 8GB 开发者_JS百科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.
- I need to run three 64-bit processes in parallel, each of which uses about 2000M of real memory.
- 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.
- 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?
The only thing that has come to my mind is that the 32-bit kernel might be the limiting factor, although I’m not sure why. I know that you can boot MacOSX with a 64-bit kernel, but then I won’t be able to load a number of 32-bit Apps, so that’s not an option for me.
Well, apparently the required workaround is to use the purge
command on MacOSX. This will clear the caches marking most of the inactive memory as free. It seems that the OS keeps as much inactive memory as possible in order to improve the responsiveness of the GUI, which unfortunately impacts the performance of some memory-intensive tools.
There is a thread with some extra information on a sister site.
I wonder whether MacOSX Server might be tuned to release more of the inactive memory for non-GUI processes…
There are evident problems in memory management in os x ...
please, take a look at my post: MAC OS X Lion performance problem - broken memory management also, i recorded a screen video, where the system starts to hang when all the free memory is gone, and inactive memory is 4-5 GB ! MAC OS X Lion performance problem - screen video
what i did ... I run the tar+bzip command, which is basic unix stuff, on the large amount of picture files, in my Pictures/ folder. Just before start, i run the "purge" command, to delete inactive/cached program data.
You can see on the video that free memory starts to drop very fast, and inactive is constantly rising. If you take a look at "bsdtar" command, it takes only a fragment of RAM, so the problem is not in this process. You cannot say that it is a program memory leak, because then the problem would not be in inactive ram, rather in active/wired.
When the free memory dropped below 100mb, i started some apps, like Safari, iPhoto and MS Word, and you can see in the video, that it takes even minutes (!) to start an app, when normally (when there is free RAM), it would take some 3-5 secs to load.
I had a very similar problem: inactive memory was never released, so the HDD was constantly paging. Upgrading to MacOsX Mountain Lion finally fixed it.
in Mac OS X, inactive memory constitutes all those processes that are not using CPU cycles currently i.e CPU usage is 0%. The active memory on the other hand is comprised of all the processes using CPU for execution. When a new process/program is launched, it becomes part of the active memory along with all other processes currently running (meaning having CPU usage). If the free memory is enough to adjust the new process in, then everything works as it should without any paging or swapping involved. If this isn't the case, then OS X starts paging out inactive processes to the disk. Now the freed up chunk of memory which once was marked as inactive, now is available as free memory.Since there is no free memory available(besides the newly created free chunk), there are 2 things that can happen to this newly created free memory chunk. Either some of the processes that were earlier active but not any longer (they are now inactive processes because they gave up the CPU), occupy this free chunk so that this again becomes part of the inactive memory, or this free chunk gets allocated to some of the active processes so it is now a part of active memory. The moral of the story is not that complicated. Whatever active program is running will run just fine even with almost no free memory available. If u have to launch a new program then initial delay is gonna be there because of increased load time as OS X would have to make room for it in memory by moving out least recently used pages (of inactive processes) to the slow disk. The real pain comes when u want to reload something into memory what OS X paged out to the disk. That is where fast I/O becomes a necessity that mostly cannot be done without.
精彩评论