Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 74650
Status: resolved
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: rtcpan.carlim [...] inboxclean.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 1.19
  • 1.23
  • 2.0401
Fixed in: 2.0500-TRIAL



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"; };
From: Carlos Lima
I've spent a lot of time trying to figure this out but it's very clear I don't understand enough of CMOP to fix it. On the other hand, I think I've fixed a memory cycle problem on CMOP::Method::Meta. My changes and tests are in https://github.com/carloslima/moose/commits/topic/rt-74650-meta-class-leak-and-memory-cycle/ I'd be more than happy to help fixing the leak issue if anyone could give me some pointers on where to start looking. ~Carlos
This was partially fixed 2.0600