File: Symdump.pm

package info (click to toggle)
apache-perl 1.3.9-14.1-1.21.20000309-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,524 kB
  • ctags: 1,743
  • sloc: ansic: 9,017; perl: 7,822; sh: 864; makefile: 695
file content (66 lines) | stat: -rw-r--r-- 1,410 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package Apache::Symdump;

use strict;
use Devel::Symdump ();
use Apache::File ();

my $X = 0;

sub logfile {
    my($r, $name) = @_;
    $r->server_root_relative("logs/$name.$$.$X");
}

sub inc_snap {
    my $r = shift;
    my $fname = logfile($r, "incdump");
    my $fh = Apache::File->new(">$fname") or die $!;
    print $fh map { "$_ = $INC{$_}\n" } sort keys %INC;
    close $fh;
}

sub handler {
    my $r = shift;
    my $fname = logfile($r, "symdump");
    my $fh = Apache::File->new(">$fname") or die $!;
    print $fh +Devel::Symdump->rnew()->as_string;
    close $fh;
    inc_snap($r);
    $X++;
}

1;
__END__

=head1 NAME

Apache::Symdump - Symbol table snapshots

=head1 SYNOPSIS

 PerlLogHandler Apache::Symdump

=head1 DESCRIPTION

Apache:Symdump uses Devel::Symdump to record snapshots of the Perl symbol
table in ServerRoot/logs/symdump.$$.$n
Where B<$$> is the process id and B<$n> is incremented each time the handler
is run.  The B<diff> utility can be used to compare snapshots and get an idea
of what might be making a process grow.  Normally, new symbols come from 
modules or scripts that were not preloaded, the Perl method cache, etc.

 % diff -u symdump.$$.0 symdump.$$.1

=head1 CAVEATS

Apache::Symdump does not cleanup up its snapshot files, do so simply by:

 % rm logs/symdump.* logs/incdump.*

=head1 SEE ALSO

Devel::Symdump(3), Apache::Leak(3)

=head1 AUTHOR

Doug MacEachern