Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'New Memory Wipe Command' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
New Memory Wipe Command
Authored by: arcticmac on Apr 11, '12 09:06:59PM

It's certainly true that it adds complication to the system to have to clear inactive memory before it can allocate more, but it doesn't account for much time, and it turns out that what was in that memory was often useful.

The way his program works (which is essentially the same as the one I linked to in my comment above) is to allocate all of your free ram, thus (assuming things are working properly) forcing the kernel to flush the disk cache, which is essentially the same operation that purge performs, though it wouldn't surprise me if 'purge' does it in a more efficient way.

As a little experiment, open a terminal and run 'time purge'. Then run it again. Notice that it doesn't take dramatically less time to run the second time than the first. Now try switching back to your web browser. Notice how it takes a bit longer than usual the first time for the window to become "active" again? Try launching a new app (e.g. I did 'open -a "Activity Monitor"' in the terminal). Notice how long it takes. Quit it and launch it again. Unless it's a much bigger app than Activity Monitor, it appears almost instantly. I think it's pretty clear that the disk cache does serve some definite value, and that clearing it too often is probably not a good idea.

On the other hand, I'll also grant that the system doesn't work perfectly. There are certainly times when I'm sitting there on top of 3/4 of a GB or more of cache/inactive memory and my system gets busy swapping away some memory or other to disk to make room for the latest thing. Which is _not_ good for performance either. Sometimes it might be worthwhile to 'purge' in a situation like that, but really it depends. Often as not, I find that quitting Safari or Xcode or Matlab or any of my other big memory-hogs is a bigger help.

What I'm trying to say is that there might be situations in which 'purge' can help, but that you shouldn't just assume that it actually makes things faster just because the 'free' RAM went up; and I definitely wouldn't advocate running it automatically repeatedly unless you have solid evidence that it increases system performance for the particular task at hand.



[ Reply to This | # ]
New Memory Wipe Command
Authored by: desepticon on Apr 11, '12 10:34:24PM

Thanks for the info. It seems to me that this guys program does something a little different from purge though. It causes no noticeable lag on my system when run. When I run purge it takes a few seconds and the system hangs. I'm not sure this program is affecting the disk cache at all. It doesn't seem to be as vicious about reclaiming memory.

Like you say I think this practice can be used in certain situations. In my case I run a Plex media server. This program has the habit of claiming more and more RAM over time and being stingy about releasing it back to the system. The computer I run this server on also multi-purposes as a MediaMac, Game System, WebServer,rtorrent setup, and generic purpose computing hub. In some instances, especially when I want to play a game, it seems to be best to start with as fresh a canvas as possible as far as inactive memory is concerned. I don't know when I might feel like playing a game, so a script such as this running automatically would allow me to "set it and forget it."

Hmmm. Thinking about this now wouldn't it be possible to attach a lauchctl watchpaths directive for certain applications you want maximum memory performance from? Does watchpaths support multiple paths?



[ Reply to This | # ]