Grokbase Groups Perl xs August 2006
FAQ

Steven N. Hirsch writes:

DESTROY is not necessarily called at the time the refcount hits zero.
Yes it is.
Perl cleans up objects without references only when leaving a scope.
i.e. that is when it decrements the REFCOUNT (in the FREETMPS/LEAVE).
D'oh. Sorry, I confused things with the way 'mortal' objects are treated.
Unless I really _am_ growing senile, aren't these recorded on a list of
things to be cleaned up on exit from a scope?
Yes. And "cleaned up" means doing an SvREFCOUNT_dec().
If when that is done count is zero the DESTROY happens.
But if something else has incremented REFCOUNT then SV lives on.

e.g. this makes

foo($a.$b) # pass a mortal as 1st arg
; # mortals cleaned up on ';'


sub foo
{
push @save,$_[0]; # REFCOUNT up
...
}

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 21 of 21 | next ›
Discussion Overview
groupxs @
categoriesperl
postedAug 7, '06 at 5:39p
activeAug 31, '06 at 7:48p
posts21
users6
websiteperl.org

People

Translate

site design / logo © 2019 Grokbase