in reply to Memory management

I found in my application that we have created threads and which not joined anywhere.

Now I have created another thread which will join the threads. After this one I got some what better memory usage. The aggressive memory eating by my application getting reduced now.

sub MemoryCleanup { while(1) { foreach(threads->list()) { $_->join() if($_->is_joinable()); } sleep(5); } }

Replies are listed 'Best First'.
Re^2: Memory management
by BrowserUk (Patriarch) on Nov 09, 2010 at 18:12 UTC
    I found in my application that we have created threads and which not joined anywhere.

    Yes. That would cause runaway memory usage.

    Whilst your solution above may work for you, there are much better ways to deal with the situation.

    One possibility it to detach the threads when you create them:

    threads->create( \&yourSub )->detach; ...

    Now the threads will go away automatically, as soon as they end and your extra thread above will be unnecessary.

    If you'd answer a few questions here, there are other, better possibilities also.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Thanks BrowserUk, Now I am getting some more memory release. Nice information for me.