Well you seem to claim the "memory gain" is acceptable.
Sorry, I was unclear. The point I was trying to make is that a program with 11 threads running will (inevitably) use more memory than the same program with 10 threads running.
So in order to determine whether there is any net growth as a result of continually replacing old threads with new ones, you need to measure the memory at points where there are the same number of threads running. Or wait for the cycle to complete and see if there was any net growth from beginning to end.
On my system that was easy to check, as memory allocated to the threads is returned to the OS when the thread dies. On Linux, where memory is returned to the process free memory pool, but not to the OS, it's impossible to tell whether the memory allocated to the process is available for use by the next thread started or not.
On releases of Perl prior to 5.8.6, it was easy to demonstrate that the cleanup of memory, when a thread dies, was not total. This was easily demonstrated by continuously creating short lived threads as fast as possible, through a steady and inexorable growth in the memory allocated to the process. With 5.8.8, that behaviour ceased (on win32 at least).
It may still be there to a lesser degree (ie. a smaller leak), but it will require a better designed mousetrap to demonstrate it. I'll have a go at adapting my program.
On the watch variable: My point was that I believe that it would be impossible to watch any type of tied variable using Tk. Which obviously includes shared vars as they are tied. So the problem is not specific to shared vars, but it shows up when you use threads, because it's so much easier to concurrently alter the value of a (watched) tied variable, when you have shared variables & threads running.
In reply to Re^6: Threads question
by BrowserUk
in thread Threads question
by xiaoyafeng
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |