You need to reuse your threads. It's a misconception that if you use detach, that somehow it all dissppaears after the thread is finished and the memory is reclaimed to the system. It is reclaimed to Perl. So what you need to do, is NOT detach, and work out a scheme to reuse your thread threads. I usually put them in a "sleeping condition", and have them periodically check to see if they should wake up and do something. It dosn't use much cpu for a thread to sleep and wake up every 50 milliseconds( or even 1 second). You may also be able to use detach , but just reuse the variable name you assign to the thread, but I havn't tested that much. All this is complicated by what you are using in your thread. Try to keep all extra objects contained completely within each thread. But it is all so complex, that you really need to show some code example, then we can help you work out solutions.
I'm not really a human, but I play one on earth.
flash japh
| [reply] |
My limited knowledge of perl memory management is that perl never (or hardly ever) free's up memory back to the OS, but that it keeps already allocated memory for itself even if it is not using it. | [reply] |
What OS are you using? How are you monitoring memory usage? You might want to check out this node about memory usage under Linux to see if it helps. If it doesn't fit, please post some code and details of your system.
Update: Fixed broken link. Thanks mpeg4codec. | [reply] |
Your link there wasn't working properly for me. If you have problems with the link above, try using this link.
| [reply] |
can you show us some code and test data so we can take a better look at your problem. | [reply] |
| [reply] |
For people using RedHat EL4 (or below), the default version of threads is 1.05. Any version after (and including) 1.23 will clear these problems out.
| [reply] |