in reply to Memory leak!

If I may be so bold as to reel everyone back in to the original question, my script still seems to be running out of memory after about an hour. If anyone would like to continue to (needlessly) debate the differences between for(;;) and while(1), go to my previously posted question Infinite Loop Question and go wild. I have tried:

closedir DIR1;

in both subroutines after I opened and read directories, and I also tried emptying out the @rmtDirList at the end of the Prog subroutine:

@rmtDirList = ();

but neither has worked yet. As I said, it is stumping me because a very similar version of the script has been running nonstop for about a three weeks now, and I never ran into this problem when developing it. In fact I am testing the problem script on exactly the same server machine that the other is currently running! Any other insights or suggestions would be greatly appreciated. Thanks!!

Replies are listed 'Best First'.
Re^2: Memory leak!
by chromatic (Archbishop) on Dec 13, 2011 at 18:47 UTC

    @rmtDirList isn't the only global I see you modify in place without clearing. Try also my other suggestion of passing in global variables, copying their values into lexicals, and leaving the globals unmodified. That's far easier in the long run than pairing up pushes and pops every place you modify a global.


    Improve your skills with Modern Perl: the free book.