| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Memory::Leak::Hunter; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$Memory::Leak::Hunter::VERSION = '0.02'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
1
|
|
|
1
|
|
133068
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
64
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Devel::Gladiator; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
2819
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
1
|
|
|
1
|
0
|
2339
|
my ($class) = @_; |
|
12
|
1
|
|
|
|
|
8
|
return bless { records => [] }, $class; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub record { |
|
16
|
3
|
|
|
3
|
0
|
4265
|
my ($self, $name) = @_; |
|
17
|
3
|
|
|
|
|
7
|
push @{ $self->{records} }, { |
|
|
3
|
|
|
|
|
38
|
|
|
18
|
|
|
|
|
|
|
time => time, |
|
19
|
|
|
|
|
|
|
count => Devel::Gladiator::arena_ref_counts, |
|
20
|
|
|
|
|
|
|
name => $name, |
|
21
|
|
|
|
|
|
|
}; |
|
22
|
3
|
|
|
|
|
394444
|
return; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub records { |
|
26
|
1
|
|
|
1
|
0
|
2078
|
my ($self) = @_; |
|
27
|
1
|
|
|
|
|
4
|
return $self->{records}; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub last_diff { |
|
31
|
4
|
|
|
4
|
0
|
4659
|
my ($self) = @_; |
|
32
|
4
|
|
|
|
|
33
|
Carp::croak('last_diff called before having 2 records') |
|
33
|
4
|
50
|
|
|
|
10
|
if @{ $self->{records} } < 2; |
|
34
|
4
|
|
|
|
|
27
|
return _diff($self->{records}[-2]{count}, $self->{records}[-1]{count}); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _diff { |
|
39
|
7
|
|
|
7
|
|
495245
|
my ($first, $second) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
15
|
my %diff; |
|
42
|
7
|
|
|
|
|
110
|
foreach my $k (keys %$second) { |
|
43
|
267
|
|
50
|
|
|
978
|
my $d = $second->{$k} - ($first->{$k} || 0); |
|
44
|
267
|
100
|
|
|
|
499
|
if ($d) { |
|
45
|
34
|
|
|
|
|
151
|
$diff{$k} = $d; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
7
|
|
|
|
|
62
|
return \%diff; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub report { |
|
54
|
1
|
|
|
1
|
0
|
537
|
my ($self) = @_; |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
3
|
my $str = ''; |
|
57
|
1
|
|
|
|
|
3
|
foreach my $r (@{ $self->{records} }) { |
|
|
1
|
|
|
|
|
4
|
|
|
58
|
3
|
|
|
|
|
14
|
$str .= sprintf "%5s, %20s", $r->{time}, $r->{name}; |
|
59
|
3
|
|
|
|
|
5
|
for my $k (sort keys %{ $r->{count} }) { |
|
|
3
|
|
|
|
|
68
|
|
|
60
|
117
|
|
|
|
|
252
|
$str .= " $k=$r->{count}{$k} "; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
3
|
|
|
|
|
14
|
$str .= "\n"; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
163
|
return $str; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Memory::Leak::Hunter - help to find memory leaks |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Experimantal usage of L |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Gabor Szabo L |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Gabor Szabo L. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
85
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
|
93
|
|
|
|
|
|
|
|