in reply to Threads Problem!

You do not give enough information for us t suggest a solution. If youre using earlier than 5.8.1, there are some known problems with memory leaks, but unless you are using large quanities of shared variables and/or not taking precautions to minimized the nadvertant sharing of datastructures and code between your threads, 5.8.0 is also quite useable. If your using earlier than 5.8.0, you should definately upgrade.

Unfortunately, beyond the sage advice in liz's Things you need to know before programming Perl ithreads, it it quite difficult to try and write down all the things that you need to look for that might be contributing to memory leaks in threaded apps. I know, because I've tried a couple of times. However, it is usually possible to eliminate (or reduce to a trivial minimum), the rate of leakage, but carefully working through the application looking for where things might be inadvertantly being shared in a way that makes it difficult for perl to clean up.

One thing that you probably shouldn't be doing is creating and destroying threads on a one-shot basis. It is hugely more efficient and creates much fewer possibilities for leaks, to create a pool of threads and dispatch elements of work to them via a queue. It's a somewhat harder way to use threads and would probably mean a fair amount of reworking of your existing application (going by the format of the snippet you posted), but the end result is usually worth the work.

Sorry to answer in the generic, but in the absence of more information, it is all that is possible.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
Wanted!

Replies are listed 'Best First'.
Re: Re: Threads Problem!
by Phantazm (Initiate) on Nov 03, 2003 at 14:05 UTC
    Thanks alot for the info.
    I will have a look at the thread pool and see if that could help me out a lil.