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.


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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^6: Threads question by BrowserUk
in thread Threads question by xiaoyafeng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.