If it were single threaded, yes. But remember threading is still Wild West territory

That's a total red-herring. Unless you are using shared variables (and even then), there is no effective difference in running two Perl threads and running two perl processes. Each thread has its own interpreter, just as each process does. And variables allocated by each interpreter are exclusive to that interpreter.

When variables die Perl only guarantees that the varname is no longer accessible, not that anything in particular has been done with the SV's behind the scenes.

That's wrong also. Reference counting means that variables allocated at any given scope are returned to the memory pool as soon as you leave that scope(*). With most other GC mechanism, those variables would be sitting around gathering electronic dust, inassessible but unreclaimed, until low memory or some other extraordinary event causes the whole program to freeze while the garbage collector scans all the programs dataspace, heap and stack,(twice at least), checking to see what is lying around and if anything else is still referencing it.

Which makes:

In fact the whole Perl memory management philosophy seems too lacidasical.

Just about the opposite of reality. Perl's GC mechanism, reference counting, is the most eager GC mechanism possible.

The only time that falls down is if you are creating circular references--as I mentioned above.

*Unless your code has passed a reference to the variables out of that scope and they have failed to let go of those references. That is, your code has done something that necessitates retention. There are a few special exceptions to do with optimisations for function lexicals also, but if they were the root of your problem, they would be known about by now.


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^7: Massive Perl Memory Leak by BrowserUk
in thread Massive Perl Memory Leak by wagnerc

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.