circ-ref.txt

class Foo {
    has callback => (is => 'rw');
    method foo { ... }
}

class Bar {
    has self => (is => 'rw');
    method bar { ... }
}

#-----------------------------------------------------------------------------
my $foo;

{
    my $bar = Bar->new;
    $foo = Foo->new(callback => sub { $bar->foo });
}

# is $bar garbage collected?

#-----------------------------------------------------------------------------
{
    my $foo = Foo->new;
    $foo->callback(sub { $foo->foo });
}

# is $foo garbage collected?

#-----------------------------------------------------------------------------
{
    my $bar = Bar->new;
    $bar->self($bar);
}

# is $bar garbage collected?