MooseX-LeakCheck - Check for leaky attributes
Define an attribute that you know should be the only remaining ref to an object when your instance is destroyed. On destruction verify the attribute is also destroyed.
package Foo; use MooseX::LeakCheck; has bar => ( is => 'ro', default => sub {[]}, leak_check => 1, ); has baz => ( is => 'ro', default => sub {[]}, leak_check => sub { my $self = shift; my ( $attr_name, $ref ) = @_; ... } ); has boo => ( is => 'ro', default => sub {[]}, # Defaults to no leak_check => 0, ); 1;
Turn on leak checking for the attribute when set to true. Generates a warning when a leak is detected. Alternatively you may provide a coderef callback to run when a leak is detected.
The coderef gets the following args: ( $self, $attr_name, \$self->{$attr_name})
Chad Granum exodist7@gmail.com
Copyright (C) 2012 Chad Granum
MooseX::LeakCheck is free software; Standard perl licence.
MooseX::LeakCheck is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
To install MooseX::LeakCheck, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::LeakCheck
CPAN shell
perl -MCPAN -e shell install MooseX::LeakCheck
For more information on module installation, please visit the detailed CPAN module installation guide.