On Wed, May 05, 2004 at 08:11:56PM -0600, Brian Hirt wrote:
> I've been running across a problem lately where a child process
> terminates because of an out of memory error. It prints Out of Memory
> once, the the process sucks up all available cpu print "Callback called
> exit." to the log file until it hit's it's 2GB max size.
>
> I have some Apache::Resource limits set, and they probably need to be
> raised, but the way the error is handled is not very graceful. I'd
> expect the child to just terminate after reporting the first error
> message. I'm not sure if this is a perl problem or a mod_perl
> problem. I'd still like to figure out how to prevent the repeating
> message from happening.
>
> Anyway, I've been pulling my hair out trying to prevent this, and I've
> finally figured out how to trap this. I have some suggestions for the
> documentation, because the following url could use some help:
>
> http://perl.apache.org/docs/1.0/guide/troubleshooting.html#Callback_called_exit
I've followed that advice and explicitly allocated memory into $^M.
I have the following in my mod_perl_startup.pl, which I run from
httpd.conf with PerlRequire /path/to/mod_perl_startup.pl
If 64K is not enough for you, try increasing the allocation.
Cheers,
Glenn
use strict;
## ----------
## ----------
## This section is similar in scope to Apache::Debug.
## Delivers a stack backtrace to the error log when perl code dies.
## Allocate 64K as an emergency memory pool for use in out of memory situation
$^M = 0x00 x 65536;
## Little trick to initialize this routine here so that in the case of OOM,
## compiling this routine doesn't eat memory from the emergency memory pool $^M
use CGI::Carp ();
eval { CGI::Carp::confess('init') };
## Importing CGI::Carp sets $main::SIG{__DIE__} = \&CGI::Carp::die;
## Override that to additionally give a stack backtrace
$main::SIG{__DIE__} = \&CGI::Carp::confess;
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html