in reply to Help me to find hidden object references....
It sounds as though you are depending on DESTROY being called when you undef an object so that it releases a DB handle? Destroy will only be called if there are no references left to that object as you seem to know but even then from my understanding of Perls lazy garbage collection there is no guarantee.
It sounds a though you are talking mod_perl??? (global cleanup phase) - is that so? Perl does some things behind the scenes for efficiency that don't help your case.
Perhaps a better way to go is simply to call a finish/eof/disconnect method on your object to get the behaviour you want when you want it, rather than depending on DESTROY, prsumbably when the object goes out of scope. If you are actively using undef why not call an appropriate finish() method?
There is a Devel::Refcount module but it is not on CPAN. Look here for the XS and PM source code. h2xs -A -n Devel::Refcount will write you a stub distro to copy these files into so you can just do the usual install.
package Test; $|++; print "Creation\n"; my $obj = new Foo; my $a = $obj; # comment in and out to see behavour change print "Undef....\n"; undef $obj; print "We have undefed!\n" unless defined $obj; print "Sleep....\n"; sleep 2; END{ print "Exiting\n" } package Foo; sub new { bless {}, shift }; sub DESTROY { print "Destroy.....\n" } __END__ Creation Undef.... We have undefed! Sleep.... Destroy..... Exiting
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|