Skip to content

Instantly share code, notes, and snippets.

@tokubass
Created May 31, 2016 05:16
Show Gist options
  • Save tokubass/328008e1cfde1a7c0bfbec083d3bfdaa to your computer and use it in GitHub Desktop.
Save tokubass/328008e1cfde1a7c0bfbec083d3bfdaa to your computer and use it in GitHub Desktop.
mod_perlのハンドラーメモリリーク例
use strict;
use warnings;
my $dis = MyDispatch->new;
$dis->print;
package MyDispatch {
use CGI;
use Apache2::Const;
use Apache2::RequestUtil;
sub new {
my $class = shift;
my $self = bless {}, $class;
__set_cleanup_handler();
$self->{q} = CGI->new;
return $self;
}
sub print {
my $self = shift;
print
$self->{q}->header,
$self->{q}->start_html('hello world'),
$self->{q}->h1('hello mini_dispatch'),
$self->{q}->end_html;
}
sub __set_cleanup_handler {
my $foo = '1' x (1024*1024);
my $r = Apache2::RequestUtil->request;#Apache2::RequestRec object
$r->push_handlers(PerlCleanupHandler => sub {
my $r = shift;
my $hoge = $foo;
});
}
}
...(略)...
<Location / >
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +SetupEnv
Options +ExecCGI
</Location>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment