![]() |
Practical mod_perl / HTML Book / | ![]() |
||
![]() |
||||
![]() |
![]() |
|||
![]() |
![]() |
|||
![]() |
||||
|
|
||||
![]() |
![]() |
|||
![]() |
22.3.10. Out of memory! |
![]() |
||
![]() |
||||
![]() |
![]() |
![]() |
||
![]() |
||||
If something goes really wrong with your code, Perl may die with an "Out of memory!" and/or "Callback called exit" message. Common causes of this are infinite loops, deep recursion, or calling an undefined subroutine.
If -DPERL_EMERGENCY_SBRK is defined, running out of memory need not be a fatal error: a memory pool can be allocated by using the special variable $^M. See the perlvar manpage for more details.
If you compile with that option and add use Apache::Debug level => 4; to your Perl code, it will allocate the $^M emergency pool and the $SIG{_ _DIE_ _} handler will call Carp::confess( ), giving you a stack trace that should reveal where the problem is. See the Apache::Resource module for the prevention of spinning httpds.
Note that Perl 5.005 and later have PERL_EMERGENCY_SBRK turned on by default.
Another trick is to have a startup script initialize Carp::confess( ), like this:
use Carp ( );
eval { Carp::confess("init") };
This way, when the real problem happens, Carp::confess doesn't eat memory in the emergency pool ($^M).
 
Continue to:
mod_perl, modperl, Apache, perl, cgi, html, mod_perl, e-commerce, scalability, free, open source, OSS, apache, squid, high availability, modperl, linux, unix, Web, www, mod_perl, webserver, admin, apache, book, webmaster, tools, modperl, guide, docs, documentation, help, mod_perl, perl, information, apache, script, errata, eric cholet, perl, apache, mod-perl, stas bekman, mod_perl, cool, perl, Apache, performance, speed, choice
![]() |
Other projects to check out: meta-religion.com is for those interested in Religious, Spiritual and Esoteric Phenomena. i-want-a-better.com is a community of people discussing what they would like to be improved in their lives and things they use and interact with. You may also want to find a healer in your area or read articles on variety of topics.