NAME
Test::Weaken - Test for leaks after weakening of circular references
VERSION
Alpha Version
This is alpha software, not at present suitable for any purpose except reading and experimentation. Among other issues, this documentation is still very inadequate.
SYNOPSIS
Frees an object and checks that the memory was freed. Intended especially for objects with circular references and weakened references, to make sure all works as expected. It can also be used in situations without circular references, but unless you suspect a bug in Perl itself, that would be a waste of time.
use Test::Weaken;
my $freed_ok = Test::Weaken::poof(
sub {
my $obj1 = new Module::Test_me1;
my $obj2 = new Module::Test_me2;
[ $obj1, $obj2 ];
}
);
FUNCTIONS
poof
sub poof { }
AUTHOR
Jeffrey Kegler
BUGS
Please report any bugs or feature requests to bug-test-weaken at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Weaken. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Test::Weaken
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
LIMITATIONS
Potential users will want to compare Test::Memory::Cycle
and Devel::Cycle
, which examine existing structures non-destructively. Devel::Leak
also covers similar ground, although it requires Perl to be compiled with -DDEBUGGING
in order to work.
This module does not look inside code references. Devel::Cycle does so if PadWalker is present, and I may enhance this module to do likewise.
This module assumes the object returned from the subroutine is self-contained, that is, that there are no references to outside memory. If there are, bad things will happen. Most seriously, to distinguish undef
's in the original data from those which result from freeing of memory, Test::Weaken
overwrites them with the number 42. Less, the results reported by Test::Weaken
will include the outside memory, probably not be what you wanted.
ACKNOWLEDGEMENTS
Thanks to jettero, Juerd and perrin of Perlmonks for their advice. Thanks also to Lincoln Stein (developer of Devel::Cycle
) for test cases and other ideas.
COPYRIGHT & LICENSE
Copyright 2007 Jeffrey Kegler, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.