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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |