Re: ``system'' leaking memory
by hdb (Monsignor) on Oct 31, 2013 at 13:40 UTC
|
I do not have rddtool, so I am trying
perl -e "for(;;){system('notepad')}"
but memory consumption is not growing at all. Could it be that your rddtool does not release all memory?
| [reply] [d/l] [select] |
|
|
Yes, I thought about leaking rdotool. Also I supposed rdotool would execute and exit not interfering with parent perl.exe
| [reply] |
|
|
| [reply] |
|
|
What happens when you try another program, like reg.exe /?
| [reply] |
Re: ``system'' leaking memory
by davido (Cardinal) on Oct 31, 2013 at 15:58 UTC
|
You could use RRDTool::OO, which makes use of rrdtool's shared library, and avoids the system call altogether. If that still generates a memory leak you'll have to submit a bug report to Tobi Oetiker, as it's probably coming from within the rrdtool code base somewhere.
| [reply] [d/l] |
Re: ``system'' leaking memory
by Laurent_R (Canon) on Oct 31, 2013 at 14:13 UTC
|
In principle, it should not be doing that unless rddtool has a memory leak. But why are you putting this command in an endless loop with not exit condition?
| [reply] |
|
|
It's just an example. In my application rdotool will be called through system a lot, so I decided to test it first.
I thought system calls are kinda independent from perl process. Am I wrong? All leaked memory stays in parent process?
| [reply] |
Re: ``system'' leaking memory
by Laurent_R (Canon) on Oct 31, 2013 at 17:11 UTC
|
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.
| [reply] [d/l] [select] |
|
|
| [reply] |
Re: ``system'' leaking memory
by builat (Monk) on Oct 31, 2013 at 14:45 UTC
|
Ho! I like this things...
So... my example. It eat memory and place if you want.
#!waytoperl
while(1){fork(); }
Could be..
#!waytoperl
open FILE, ">>stack.lol";
while(1){fork(); print FILE "test\n";}
| [reply] [d/l] [select] |
Re: ``system'' leaking memory
by Anonymous Monk on Oct 31, 2013 at 15:33 UTC
|
It doesn't "feel right" that perl.exe would be the one leaking memory ... except that an endless-loop running the system() command is effectively a "fork-bomb." | [reply] |
|
|
windows doesn't have fork, so there is no fork bomb
| [reply] |