php-fastcgi and memory leaks

Reinis Rozitis r at roze.lv
Tue Mar 25 14:30:24 MSK 2008


Thats a common issue (at least for me). Although php leaks itself with every 
version less there are still quite a bunch of extensions outside that dont 
handle the memory bits the right way.

As a workarround I use this patch 
http://devzone.zend.com/content/patch/pat38.txt

Its pretty old and made for php4 but with little tweaks you can apply also 
to php5 (I could make a diff and throw in here). The basic idea is you have 
an extra setting PHP_FCGI_MAX_RAM_MB - you can limit at what memory usage 
the php child should handle the last request and die (so the master process 
can spawn a new one - similar to PHP_FCGI_MAX_REQUESTS ).

This solution is better because you dont accidently kill a process which is 
in a middle of generating a response.

rr

----- Original Message ----- 
From: "Phillip B Oldham" <phill at theactivitypeople.co.uk>
To: <nginx at sysoev.ru>
Sent: Tuesday, March 25, 2008 11:44 AM
Subject: php-fastcgi and memory leaks


> Further to the email below, I'm still having problems with PHP5 fastcgi
> and nginx. I'm finding that php slowly takes up 100% of the available
> memory and starts to drop connections at around 70%. At the moment I've
> got monit restarting the fastcgi processes when the memory usage hits
> 70%, but this isn't optimal as the scripts I'm running shouldn't take
> anywhere near that on a virtual server with 300MB dedicated ram.
>
> I'm wondering whether anyone else has come across the same problem
> running php5 fastcgi who has managed to find a fix or work-around?







More information about the nginx mailing list