Check for memory leaks and circular memory references
Version 1.04
Perl's garbage collection has one big problem: Circular references can't get cleaned up. A circular reference can be as simple as two reference that refer to each other:
my $mom = { name => "Marilyn Lester", }; my $me = { name => "Andy Lester", mother => $mom, }; $mom->{son} = $me;
\*(C`Test::Memory::Cycle\*(C' is built on top of \*(C`Devel::Cycle\*(C' to give you an easy way to check for these circular references.
use Test::Memory::Cycle;
my $object = new MyObject; # Do stuff with the object. memory_cycle_ok( $object );
You can also use \*(C`memory_cycle_exists()\*(C' to make sure that you have a cycle where you expect to have one.
Checks that $reference doesn't have any circular memory references. Checks that $reference does have any circular memory references. Checks that $reference doesn't have any circular memory references, but unlike \*(C`memory_cycle_ok\*(C' this will also check for weakened cycles produced with Scalar::Util's \*(C`weaken\*(C'. Checks that $reference does have any circular memory references, but unlike \*(C`memory_cycle_exists\*(C' this will also check for weakened cycles produced with Scalar::Util's \*(C`weaken\*(C'.
Written by Andy Lester, \*(C`<andy @ petdance.com>\*(C'.
Please report any bugs or feature requests to \*(C`bug-test-memory-cycle at rt.cpan.org\*(C', or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Memory-Cycle>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Test::Memory::Cycle
You can also look for information at:
AnnoCPAN: Annotated \s-1CPAN\s0 documentation <http://annocpan.org/dist/Test-Memory-Cycle>
\s-1CPAN\s0 Ratings <http://cpanratings.perl.org/d/Test-Memory-Cycle>
\s-1RT:\s0 \s-1CPAN\s0's request tracker <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Memory-Cycle>
Search \s-1CPAN\s0 <http://search.cpan.org/dist/Test-Memory-Cycle>
Thanks to the contributions of Stevan Little, and to Lincoln Stein for writing Devel::Cycle.
Copyright 2006, Andy Lester, All Rights Reserved.
You may use, modify, and distribute this package under the same terms as Perl itself.