in reply to Re: Memory leaks and circular references
in thread Memory leaks and circular references
Expected output: (nothing)package Top; sub new { my $class = shift; my $s = bless { }, $class; $s->{bottom} = Bottom->new( $s ); return $s; } #===================================== package Bottom; use Scalar::Util 'weaken'; sub new { my ($class, $top) = @_; my $s = bless { top => $top }, $class; weaken($s->{top}); return $s; } #===================================== package main; use strict; use warnings 'all'; use Devel::Cycle; my $top = Top->new(); my $bottom = $top->{bottom} or die "NO BOTTOM!"; $top = $bottom->{top} or die "NO TOP!"; find_cycle( $top ); find_cycle( $bottom );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Memory leaks and circular references
by shmem (Chancellor) on Sep 07, 2008 at 00:02 UTC | |
by jdrago_999 (Hermit) on Sep 07, 2008 at 00:56 UTC | |
by jdrago_999 (Hermit) on Sep 07, 2008 at 01:05 UTC | |
by Joost (Canon) on Sep 07, 2008 at 01:36 UTC |