From the perlguts manpage:

       There are some convenience functions available that 
       can help with the destruction of xVs.  These
       functions introduce the concept of "mortality".  An
       xV that is mortal has had its reference count marked
       to be decremented, but not actually decremented,
       until "a short time later".  Generally the term
       "short time later" means a single Perl statement,
       such as a call to an XSUB function.  The actual
       determinant for when mortal xVs have their reference
       count decremented depends on two macros, SAVETMPS and
       FREETMPS.  See perlcall and perlxs for more details
       on these macros.

       "Mortalization" then is at its simplest a deferred
       "SvREFCNT_dec".  However, if you mortalize a variable
       twice, the reference count will later be decremented
       twice.

       "Mortal" SVs are mainly used for SVs that are placed
       on perl's stack.  For example an SV which is created
       just to pass a number to a called sub is made mortal
       to have it cleaned up automatically when it's popped
       off the stack. Similarly, results returned by XSUBs
       (which are pushed on the stack) are often made
       mortal.

Flo


In reply to Re: XS-ive Mortality. (or when to use sv_2mortal()) by rafl
in thread XS-ive Mortality. (or when to use sv_2mortal()) by BrowserUk

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.