Subject: | TryCatch leaks memory when used with MooseX::Declare |
Distribution: TryCatch
Version: 1.003000
Perl: 5, version 14, subversion 2 (v5.14.2) built for i686-linux-gnu-
thread-multi-64int
uname -a: Linux pineapple 3.2.0-35-generic-pae #55-Ubuntu SMP Wed Dec 5
18:04:39 UTC 2012 i686 i686 i386 GNU/Linux
Description: The try block created by the distribution TryCatch traps
references when used in combination with MooseX::Declare.
Subject: | try_catch_test.pl |
use strict;
use warnings;
use Devel::Refcount qw/refcount/;
use MooseX::Declare;
class FooEval {
method bar () {
eval {
$self->baz;
};
}
method baz () {
return 2 + 2;
}
};
class FooTryTiny {
use Try::Tiny;
method bar () {
try {
$self->baz;
} catch {
};
}
method baz () {
return 2 + 2;
}
};
class FooTryCatch {
use TryCatch;
method bar () {
try {
$self->baz;
} catch ($err) {
};
}
method baz () {
return 2 + 2;
}
};
my @classes = qw/FooTryCatch FooTryTiny FooEval/;
foreach (@classes) {
my $foo = $_->new;
print "devel refcount pre-$_: "
. refcount($foo) . "\n";
for (1 .. 5) {
$foo->bar;
}
print "devel refcount post-$_: "
. refcount($foo) . "\n\n";
}
#devel refcount pre-FooTryCatch: 1
#devel refcount post-FooTryCatch: 6
#
#devel refcount pre-FooTryTiny: 1
#devel refcount post-FooTryTiny: 1
#
#devel refcount pre-FooEval: 1
#devel refcount post-FooEval: 1