On Thu, 10 Aug 2006, Nick Ing-Simmons wrote:

> >> DESTROY seems to be the way to do that. So I defined a DESTROY method in
> >> my XS code:
> >> 
> >>   void
> >>   DESTROY(c)
> >>           my_c_structure_t* c
> >>       CODE:
> >>           my_c_structure_unref(c);
> >> 
> >> 
> >> Unfortunately DESTROY won't be called when the perl objects reference
> >> count reaches zero as it seems to be the case in pure-perl world. What's
> >> the difference between pure-perl code and XS code with regard to
> >> DESTROY? How can I get my XS DESTROY method called properly?
> >
> >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?

Steve

Reply via email to