On Tue, Aug 08, 2006 at 08:05:17AM -0400, Steven N. Hirsch wrote: > DESTROY is not necessarily called at the time the refcount hits zero. > Perl cleans up objects without references only when leaving a scope. If > you need more immediate action, just undef them yourself at the point > they're no longer needed.
Given the following piece of code: package Foo; sub new { bless {}, 'Foo' } sub DESTROY { print "Destroying @_\n" } package main; { my $f = Foo->new; } This produced the following output: Destroying Foo=HASH(0x814f720) If I run the same code as in main with my class created using XS code, which has a similar constructor and deconstructor doesn't give me any output. Is the reason for DESTROY not being called in the code which uses it or in the XS code itself? I suspect the latter as the same code calls DESTROY if the class I use is declared with pure-perl. -Flo -- BOFH excuse #239: CPU needs bearings repacked
signature.asc
Description: Digital signature