Some times ago, I noticed that doing a lot of IO operation on encrypted loopback partition (like FileVault disk images) was trashing my system memory : after a while, the system began to swap a lot. I first thought some app was allocating huge parts of memory, but that was not the case.
At this time I suspected some memory leaks in the encryption or the disk image code of the Mac OS kernel. So I tried to do a lot of IO on a regular HFS partition. The same issue was present, but the swap usage was increasing slowier this time. The only solution I found to avoid this, was not to use disk intensive applications.
Unfortunetaly, as now use my mac to process RAW picture using Adobe Lightroom and this is a disk intensive application, so I bought 1 Go of memory to double the amount of RAM available for Mac OS. I was hopping this would definitevely solve my swap issue.
This was not the case, when I process a bunch of RAW file in a short amount of time, the system cannot refrain itself from swapping. Lightroom only eat 800M of memory, and while no other application if running. This only happen while using intensive disk IO operation (eg: processing RAW files or compiling many java files) and after the application is shut down the amount of physical memory used by the system is really high, so I come to conclusion that the IO cache of the kernel is just a piece of crap, eating a lot of memory without trying to figure out if there is enough memory to cache something : swapping memory pages holding disk cache is just stupid.
Is someone else is experiencing same issues, please let me know !
Display comments as (Linear | Threaded)
Interresting reads :
The issue is not new : it is present since the first release of Mac OS X !
The memory management of that system really sucks !
This first link is quite useless since the guys don't know a thing about modern memory management. Not that OS X accounting of disk cache as used memory is helpful in this regard but hey, who said these numbers really should mean anything to an untrained eye.
As of the VM (virtual memory) subsystem: It's as good as it gets. At least as good as on Linux and probably better than on Windows.
Swapping unused memory to disk to free up some for disk cache may be a good thing. Some apps allocate more memory than they really need at the moment and swapping some of it out may be a good idea.
I've got the same issues with my Powerbook and 4 GB of RAM. If I do any kind of high-disk-activity stuff (compiling large libraries with XCode or handling more than a few hundred photos in Aperture) my free memory plummets.
On most other UNIX-style systems I've used, this is normal and expected, and as you open new applications or as your application expands in memory, the file system cache reduces in size to ensure no unnecessary swapping.
This does not seem to happen on Mac OS X; if I have an album of say 1000 photos in Aperture, as I browse through each one, loading it into memory, possibly making changes etc, it will eventually start swapping memory to disk, even though the Aperture process itself may only reach 1 GB, and my total memory usage from all processes may be about 1.5-2GB. I can have 2 GB "unaccounted for" in terms of processes (i.e. it's being used for filesystem cache), and yet it'll start swapping to disk as I access new files.
This is utterly ridiculous! The filesystem cache should be speeding things up, not slowing them down by having to swap out memory to the disk it's attempting to improve performance on!!!
That's true. Same issues on OSX 10.6.5, I have a few GB of free RAM, but OSX still pages the memory contents out. For no reason at all. So if I launch an app or access contents that really, really should still be held in RAM... well they're not anymore. F*ck.
Because for some completely dumb and stupid reason OSX will trash them so that you can have huge amounts of free RAM. What the hell is that?
To make matters worse, I have a feeling that sleeping/waking the system a few times makes this worse. Either sleep mode pushes some stuff out, or it slows memory management down completely after wakeup. OSX is way snappier in terms of memory use straight after launch, then with time it only gets worse.
If you have the developer tools installed, there is a command 'purge' that clears 'Inactive Memory' that is shown in the 'Memory' section of the utility 'Activity monitor'. Before I just used it, over 1/2 of my machine's memory was listed as inactive (Dark Blue) and I could hear a lot of disk access. After typing 'purge' into a 'Terminal' window, no more disk access could be heard, practically all of the Dark Blue inactive memory went to green (Free) and the running programs all seem to be fine.
Powered by s9y