Out of memory: system();

T. 'Nifty New Hat' Mitchell mitch48 at sbcglobal.net
Tue Jun 15 00:22:02 UTC 2004


On Fri, Jun 11, 2004 at 01:45:00PM -0400, Ed K. wrote:
> 
> I must call system(....) about 300,000 times from a process that has 175MB 
> allocated on a computer with only 256MB of RAM. But after about the 5,000th 
> call, i get an out of memory error (errno: 12 Cannot allocate memory) when 
> I call the system function.
> 
> Anyone heard of this? is there something that I should free? why is my 
> 'Committed_AS' at 3TB?

Can you check to see if your sequence is generating a pile 
of orphan/zombie processes.

In general a child process will continue to consume a process slot
until the parent or init gathers up the return status.  See the wait()
system call and perhaps pcntl_wait() in php.

A zombie process has one task left; return it's exit() status to
someone.  Of interest ps can cause an implied wait() system call and
users that have bad scripts might never see their bug.  i.e. check
from a user account not equal to the one running the script if you
can.

Look for & in scripts.... 

If you need to, there are "C" and shell tricks to disconnect from the
controlling (parent) process in ways that init will inherit the
process.  Then init will clean things up for you and toss the value
that wait() returns when the child exits.  However this strategy in a
blind loop can fill up the system with 'too' many processes and things
can bog down as the system swaps badly or gets IO bound.



-- 
	T o m  M i t c h e l l 
	/dev/null the ultimate in secure storage.





More information about the fedora-list mailing list