Devel::Leak - Utility for looking for perl objects that are not reclaimed.
use Devel::Leak; ... setup code my $count = Devel::Leak::NoteSV($handle); ... code that may leak Devel::Leak::CheckSv($handle);
Devel::Leak has two functions NoteSV and CheckSV.
NoteSV
CheckSV
NoteSV walks the perl internal table of allocated SVs (scalar values) - (which actually contains arrays and hashes too), and records their addresses in a table. It returns a count of these "things", and stores a pointer to the table (which is obtained from the heap using malloc()) in its argument.
CheckSV is passed argument which holds a pointer to a table created by NoteSV. It re-walks the perl-internals and calls sv_dump() for any "things" which did not exist when NoteSV was called. It returns a count of the number of "things" now allocated.
Note that you need a perl built with -DDEBUGING for sv_dump() to print anything, but counts are valid in any perl.
If new "things" have been created, CheckSV may (also) report additional "things" which are allocated by the sv_dump() code.
This little utility module was part of Tk until the variable renaming in perl5.005 made it clear that Tk had no business knowing this much about the perl internals.
Nick Ing-Simmons <nick@ni-s.u-net.com>
To install Devel::Leak, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Devel::Leak
CPAN shell
perl -MCPAN -e shell install Devel::Leak
For more information on module installation, please visit the detailed CPAN module installation guide.