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


In reply to Re: Help me to find hidden object references.... by tachyon
in thread Help me to find hidden object references.... by Beechbone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.