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


Click here to return to the 'Don't waste your time with this' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Don't waste your time with this
Authored by: plambert on Nov 21, '05 11:11:03AM

This is entirely unnecessary. Mac OS X's virtual memory management is not this stupid, and doesn't need your help.

When a process requests memory, it is allocated to the process in its virtual memory space.

When the process actually uses the memory it has allocated, it gets real memory to do so.

When the process is done using the memory and deallocates it, the OS marks that real memory as "inactive", but doesn't remove it from the process's virtual memory space. This saves a little bit of time if the process later requests additional memory.

When another processes needs to use real memory, it is allocated from free memory first, then from "inactive" memory. Neither requires anything to be paged to disk, etc.

By restarting apache repeatedly, you are ensuring that the memory must be allocated "fresh" every time. This isn't a lot of effort, but it's entirely unnecessary! That was already done the first time the process requested it. Once the process is done with it, it's entirely available to other applications, no matter what you think the numbers mean, that you see in Activity Monitor.app or /usr/bin/top.

It's a really silly idea to think that it's worth stopping and restarting processes every five minutes, given the hundreds of man years of development that have gone into the kernel's memory management techniques. The kernel knows a _lot_ more about how to manage memory than we individuals do. Just like you wouldn't rebuild the engine in your car with entirely new headers, valves, and cylinders unless you really believed you knew more about tuning engines for your situation than the manufacturer did, you probably shouldn't worry about the low levels of memory management on your OS until you truly understand what it's already doing for you.

Trust the kernel and the kernel developers. They've been solving these problems for a very, very long time.

[ Reply to This | # ]