On Jan 5, 2004, at 10:44 AM, James Edward Gray II wrote:
DESTROY() is the traditionally accepted place to do something like
break a circular reference

Bzzzt! :-)


DESTROY can't be called *until* the circular reference is broken
(or the script exits and everything gets destroyed, regardless of
refcount).

e.g.

Normally $x is destroyed on scope exit:

  % perl -e 'sub DESTROY { warn } bless my $x = []'
  Warning: something's wrong at -e line 1.

But with a circular reference it can't be destroyed until the
script exits, which means it leaks.

  % perl -e 'sub DESTROY { warn } my $x; bless $x = \$x'
  Warning: something's wrong at -e line 1 during global destruction.

--
Steve




-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to