line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Leak; |
2
|
1
|
|
|
1
|
|
1954
|
use 5.005; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
53
|
|
3
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
4
|
|
|
|
|
|
|
require DynaLoader; |
5
|
1
|
|
|
1
|
|
16
|
use base qw(DynaLoader); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
153
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
bootstrap Devel::Leak; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
1; |
11
|
|
|
|
|
|
|
__END__ |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Devel::Leak - Utility for looking for perl objects that are not reclaimed. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Devel::Leak; |
20
|
|
|
|
|
|
|
... setup code |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $count = Devel::Leak::NoteSV($handle); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
... code that may leak |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Devel::Leak::CheckSV($handle); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Devel::Leak has two functions C<NoteSV> and C<CheckSV>. |
31
|
|
|
|
|
|
|
|
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. |
36
|
|
|
|
|
|
|
|
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. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 CAVEATS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Note that you need a perl built with -DDEBUGGING for |
45
|
|
|
|
|
|
|
sv_dump() to print anything, but counts are valid in any perl. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
If new "things" I<have> been created, C<CheckSV> may (also) report additional |
48
|
|
|
|
|
|
|
"things" which are allocated by the sv_dump() code. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 HISTORY |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This little utility module was part of Tk until the variable renaming |
53
|
|
|
|
|
|
|
in perl5.005 made it clear that Tk had no business knowing this much |
54
|
|
|
|
|
|
|
about the perl internals. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 AUTHOR |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Nick Ing-Simmons <nick@ni-s.u-net.com> |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|