ID: 32220 Updated by: [EMAIL PROTECTED] Reported By: kameshj at fastmail dot fm -Status: Assigned +Status: Open Bug Type: Apache2 related Operating System: * PHP Version: 5CVS, 4CVS (2005-03-25) Assigned To: zeev
Previous Comments: ------------------------------------------------------------------------ [2005-03-25 02:05:13] [EMAIL PROTECTED] Zeev, here's another thread issue, can you take a look in the patch? ------------------------------------------------------------------------ [2005-03-25 02:04:47] [EMAIL PROTECTED] Assuming this is not fixed in latest HEAD, PHP_5_0 or PHP_4_3 CVS branches. ------------------------------------------------------------------------ [2005-03-07 15:06:48] kameshj at fastmail dot fm Description: ------------ Run apache2 in a worker thread model with the following settings StartThreads 3 MaxSpareThreads 4 MaxThreads 10 Loadtests on a very simple php scripts like the one that calls phpinfo() at regular intervals of 5 minutes causes a memory leak(Not really a leak but huge unused memory that gets freed at tsrm_shutdown) This causes the memory consumed by the apache2 procsss to shoot up. ---Investigation Apache2 to handle the concurrent requests increases the number of child threads to max of MaxThreads when no more request to server it kills the threads till the number of threads comes to MaxSpareThreads. In the case of setting given above after the load test of 10 simultaneous requests, Apache kills 6 threads (As MaxThreads-MaxSpareThreads = 10-4 = 6). The thread_resources momory associated with these 6 threads still not freed as soon as the corresponding thread is killed. These kind of spurt loads at regular intervals causes lots of such thread_resources memory to get accumulated not being used for any real purpose. Only when the sapi module comes down it calls tsrm_shutdown then these thread_resources are getting freed. Attaching the patch to fix the issue is available at http://puggy.symonds.net/~kameshj/TSRM.c.patch This patch has a few clean up to existing ts_free_thread. This patch registers ts_free_thread as thread cleanup routine. Reproduce code: --------------- Run apache2 in a worker thread model with the following settings StartThreads 3 MaxSpareThreads 4 MaxThreads 10 write a simple test.php <?php phpinfo(); ?> Run a load test with ab ab -n 40 -c 10 Wait for 5 minutes ab -n 40 -c 10 Wait for 5 minutes ab -n 40 -c 10 Wait for 5 minutes ab -n 40 -c 10 Expected result: ---------------- In the case of setting given above after the load test of 10 simultaneous requests, Apache kills 6 threads (As MaxThreads-MaxSpareThreads = 10-4 = 6). The thread_resources momory associated with these 6 threads still not freed as soon as the corresponding thread is killed. These kind of spurt loads at regular intervals causes lots of such thread_resources memory to get accumulated not being used for any real purpose. Only when the sapi module comes down it calls tsrm_shutdown then these thread_resources are getting freed. Actual result: -------------- thread_resources of a thread that gets killed should get freed as soon as it dies rather than waiting till the tsrm_shutdown ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32220&edit=1