Subject: | Moose::Meta::Class->create_anon_class->make_immutable leaking? |
I'm facing some issues with ->create_anon_class leaking and am trying to
figure out what I'm doing wrong.
So far I've isolated it to possibly a bug on Moose.
I'm using Test::LeakTrace on the tests and to rule out any
misinterpretation of the output I wrote the .pl so I could watch memory
consumption of the process.
Tried on:
perl 5.10, Moose 1.19 and 1.23
perl 5.14, Moose 2.0401
Debian & Ubuntu boxes
The same files are available at https://gist.github.com/1728543
Please, let me know if there is anything I can help with.
Thanks!
~Carlos
Subject: | leak_try.pl |
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Moose;
while(1) {
#Moose::Meta::Class->create_anon_class; #works fine
Moose::Meta::Class->create_anon_class->make_immutable; #leaks
sleep(0.7);
}
Subject: | leak.t |
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Test::More tests => 3;
use Test::NoWarnings;
use Test::LeakTrace;
use Moose;
do {
package DummyRole;
use Moose::Role;
sub myname { "I'm a role" }
};
subtest "Passing" => sub {
leaks_cmp_ok {
my $a = { a=>1 };
my $b = { a=>$a, b=>1 };
$a->{b} = $a;
} '=', 3, "Test::LeakTrace sanity check";
no_leaks_ok {
my $a = "Abc";
my $b = {a=>5};
} "Test::LeakTrace sanity check";
no_leaks_ok {
Moose::Meta::Class->create_anon_class->new_object;
} "Plain anonymous class is leak-free";
no_leaks_ok {
Moose::Meta::Role->initialize('DummyRole2')
} 'Plain role is leak-free';
no_leaks_ok {
Moose::Meta::Class->create('DummyClass2')->new_object;
} "Plain class is leak-free";
};
subtest "Failing" => sub {
no_leaks_ok {
Moose::Meta::Class->create('DummyClass', roles => ['DummyRole'])->new_object;
} "Plain class with role is leak-free";
no_leaks_ok {
Moose::Meta::Role->create_anon_role;
} 'Plain anonymous role is leak-free';
no_leaks_ok {
my $o = Moose::Meta::Class->create_anon_class;
$o->make_immutable;
$o->new_object
} "Plain immutable anonymous class is leak-free";
};