thecerial has asked for the wisdom of the Perl Monks concerning the following question:

Please look at the following code. it presents a sub routine that takes links from an array and creates a thread to scan for the content of the link. i tried to free the memory of the threads after finishing them, but they still consume memory. when i use the programm more than 2 minutes all the main memory is used up. where is the error and how to fix it? here is the problem: http://zoozle.net/source.txt thanks alot yours, sebastian

Replies are listed 'Best First'.
Re: Programming with Threads - Memory Leak
by BrowserUk (Patriarch) on Jul 29, 2005 at 23:25 UTC

    If you start by making your code strict complient and add error checking to your IO, you'll likely fix some of your problems.

    However, the likely main problem with your program is it's design. Your confusing use of Tie::File, intermediate lists in flocked files, duplicating large arrays, and global variables.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.