I just found one example of the sort of thing that scares me in threads:

/* The code below checks that anything living on the tmps stack and has been cloned (so it lives in the ptr_table) has a refcount higher than 0 If the refcount is 0 it means that a something on the stack/context was holding a reference to it and since we init_stacks() in perl_clone that won't get cleaned and we will get a leaked scalar. The reason it was cloned was that it lived on the @_ stack. Example of this can be found in bugreport 15837 where calls in the parameter list end up as a temp One could argue that this fix should be in perl_clone */ while (tmps_ix > 0) { SV* sv = (SV*)ptr_table_fetch(PL_ptr_table, tmps_tmp[tmps_ix +]); tmps_ix--; if (sv && SvREFCNT(sv) == 0) { SvREFCNT_inc(sv); SvREFCNT_dec(sv); } }

I do not even begin to understand the reasoning or magic that lies behind the need to serially increment and then decrement the refcount of an SV if you've just tested it and it is currently set to 0?

It's this kinda thing that has made me wary of playing with refcounts.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

In reply to Re^9: Techniques On Saving Memory by BrowserUk
in thread Techniques On Saving Memory by Limbic~Region

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.