Saturday, May 21, 2005

memory leak in apache


I think that the server problem that I mentioned before is a memory leak in apache.  When I restart apache, each of the worker threads take up a certain amount of memory.  Then I make a request to a simple php script, and then the resident memory has increased after.


The simple script that I am using is:



<?php
phpinfo();
?>



Before running the script here is the memory used by apache:



root    21667  0.0  2.4 22556 11580 ?      S    18:13  0:06 /usr/sbin/httpd
apache    4002  0.0  2.4 22596 11636 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4003  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4004  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4005  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4006  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4007  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4008  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4009  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd


Then after running the script:



root    21667  0.0  2.4 22556 11580 ?      S    18:13  0:06 /usr/sbin/httpd
apache    4002  0.0  2.4 22708 12004 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4003  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4004  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4005  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4006  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4007  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4008  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd
apache    4009  0.0  2.4 22580 11600 ?      S    23:14  0:00 /usr/sbin/httpd


It appears that the worker thread that handled the request is now using about 100KB more memory.  This is not a real big deal for a small file like this, but for this blog, the worker thread grows about 12MB.


I assume that once a thread is done with a request, all of the memory used for that request should be freed.


I have temporarily fixed this in two ways:


  1. Reduced the maximum number of requests that a single thread has to handle to 50

  2. I now call "/etc/init.d/httpd graceful"to restart apache once an hour


Next I want to look through all of the modules that are being included to see if I can disable some to free memory

No comments:

Post a Comment

Mastering Matter: Seamless Smart Home Integration with Network Segmentation

I’ve been intrigued by the idea of integrating devices with Matter for some time. My smart home setup includes a pair of SwitchBot Hubs, som...