* minor documentation fix
[Devel-Leak.git] / Leak.pm
blob83dbe17b6ad02fd7fe2fa48348c075f5164f76bf
1 package Devel::Leak;
2 use 5.005;
3 use vars qw($VERSION);
4 require DynaLoader;
5 use base qw(DynaLoader);
6 $VERSION = '0.05';
8 bootstrap Devel::Leak;
11 __END__
13 =head1 NAME
15 Devel::Leak - Utility for looking for perl objects that are not reclaimed.
17 =head1 SYNOPSIS
19 use Devel::Leak;
20 ... setup code
22 my $count = Devel::Leak::NoteSV($handle);
24 ... code that may leak
26 Devel::Leak::CheckSV($handle);
28 =head1 DESCRIPTION
30 Devel::Leak has two functions C<NoteSV> and C<CheckSV>.
32 C<NoteSV> walks the perl internal table of allocated SVs (scalar values) - (which
33 actually contains arrays and hashes too), and records their addresses in a
34 table. It returns a count of these "things", and stores a pointer to the
35 table (which is obtained from the heap using malloc()) in its argument.
37 C<CheckSV> is passed argument which holds a pointer to a table created by
38 C<NoteSV>. It re-walks the perl-internals and calls sv_dump() for any "things"
39 which did not exist when C<NoteSV> was called. It returns a count of the number
40 of "things" now allocated.
42 =head1 CAVEATS
44 If new "things" I<have> been created, C<CheckSV> may (also) report additional
45 "things" which are allocated by the sv_dump() code.
47 =head1 NOTES
49 Note that perls older than 5.6.0 need to be built with -DDEBUGGING
50 for sv_dump() to print anything, but counts are valid in any perl.
52 =head1 HISTORY
54 This little utility module was part of Tk until the variable renaming
55 in perl5.005 made it clear that Tk had no business knowing this much
56 about the perl internals.
58 =head1 AUTHOR
60 Nick Ing-Simmons <nick@ni-s.u-net.com>
62 =cut