Defining a trigger on an attribute seems to cause a memory leak when redefining the attribute. It seemed as long as there was a coderef, even an empty coderef, the leak would be produced.
Example that will show the actual leak
package Foo;
use Mouse;
has 'bar' => (
is => 'rw',
trigger => sub { }
);
1;
package main;
my $foo = Foo->new(bar => 'TEST');
while (1) {
$foo->bar('A' x (1000000));
sleep 1;
}
1;
And the test that shows the leak:
use Test::More;
use Test::LeakTrace;
plan tests => 1;
no_leaks_ok {
my $foo = Foo->new(bar => 'TEST');
$foo->bar('bar');
} 'Foobar';
Defining a trigger on an attribute seems to cause a memory leak when redefining the attribute. It seemed as long as there was a coderef, even an empty coderef, the leak would be produced.
Example that will show the actual leak
And the test that shows the leak:
I was able to reproduce on 5.8, 5.14, and 5.18.