php-fastcgi and memory leaks

Grzegorz Nosek grzegorz.nosek at
Mon Mar 31 16:06:51 MSD 2008


On Mon, Mar 31, 2008 at 12:55:16PM +0100, Phillip B Oldham wrote:
> I'm confused - when using a command similar to the one below, is it 
> spawn-fcgi handling memory or php-cgi? When I check the processlist (ps 
> aux) I see 4 instances of "php-cgi", each one with a slowly growing 
> memory usage.

If you use 'ps auxf', you'll probably see that one of the php-cgi
processes is the master, with all others hanging off from it as its
children. By that time, spawn-fcgi is long gone (it called exec...() and
became the master php process). BTW, do you really see increasing memory
usage on all the processes including the parent?

spawn-fcgi isn't really a process manager, it just starts your fastcgi
server and hopes for the best. Anyway, only the php interpreter is to
blame here.

> Maybe its the app I'm using which doesn't finish correctly. Its 
> contributed to by a few different developers, some of which are new to 
> the system and might not be finishing their scripts with the correct 
> return state.

It shouldn't matter at all, the memory used for e.g. php code and
variables should get properly freed at the end of the request. You might
leak resources (database connections etc.) though. Are you using any
non-standard php extensions?

Best regards,
 Grzegorz Nosek

More information about the nginx mailing list