Created
May 31, 2016 05:16
-
-
Save tokubass/328008e1cfde1a7c0bfbec083d3bfdaa to your computer and use it in GitHub Desktop.
mod_perlのハンドラーメモリリーク例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
$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; | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...(略)... | |
<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