Regularly recapture memory used by Apache

Nov 21, '05 05:51:00AM

Contributed by: schmunk

I recognized that my Apache 1.3 consumes a lot of memory during different tasks (eg. running phpDocumentor multiple times allocates about 80 MB of RAM for every instance). You can gracefully restart your web server to free the allocated memory, let's say every five minutes. Graceful means that no process is killed while it is running.

I put this into a cronjob (for root) with crontab -e:

0-59/5 * * * * /usr/sbin/apachectl graceful
Note: This is probably only suitable for development web servers, since it will disrupt access to the server during the graceful restart...

[robg adds: I don't know enough about OS X's memory management to determine whether this action is really necessary or not. But I do know that the httpd processes can take a fair chunk of real memory, especially as you ask them to do more complicated things. Hence, here's a way to recapture that RAM ... I'll leave it to the comments to discuss the merits of doing so!]

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20051115043110429