I've seen that if one has a single core, then one can avoid many race conditions because only one thread ever runs at a time.

I completely agree that moving from single-cpu multi-threading to multi-cpu multi-threading often causes latent bugs to become glaringly obvious. Though I think this is more apparent with compiled-to-native code than ithreads, simply because you do not get the 'atomicity' of native machine instructions with Perl op-codes.

The basis of my gut feel is the lack of any great program level memory allocations, and the inherent simplicity of the OPs demo code.

Given the latest info from the OP, that creating & destroying threads consisting soley of sub{ 1; } causes fast, massive leaks on his system, I have to suspect that the leak is inherent in the implementation of the creation and freeing of interpreter structures on his platform.

The big difference between *nix and Win32 in this regard is that Win32 returns memory segments allocated by the creation of threads to the OS. So, even if during the creation of the internal structures required to create a new interpreter, there is some circular reference or other reference counting error, that on the *nix system means that some part of it does not get free'd back to the memory pool for re-use, on the win32 system, the entire kit'n'kaboodle gets given back to the OS, so reference counting errors do not persist.


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^9: memory leaks with threads (race of 1) by BrowserUk
in thread memory leaks with threads by misc

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.