in reply to ``system'' leaking memory

Having system calls in an endless loop certainly does not seem to be the right thing to do (which is why I asked the question in the first place), but it is really not the same thing as just forking endlessly in a while (1)loop. Admittedly, system will fork a new process each time, but the parent will wait for the child to complete before iterating again into the loop to create a new child, so that you have at most two processes present (and only one really running) at any point of time. It might probably end up exhausting some of the system resources, as not everything may be reclaimed by Perl or the System, but it should be rather slow.

I just tried this:

$ perl -e 'system("ls") while 1'

and monitored the system. The numbers of processes, threads, handles, etc. are just oscillating between two values, but not increasing, but the used memory is increasing very slowly but steadily.

Replies are listed 'Best First'.
Re^2: ``system'' leaking memory
by Anonymous Monk on Oct 31, 2013 at 22:54 UTC
    :*{ ... of course