Practical mod_perl / HTML Book /



previous page: 22.3.9. Callback called exit
  
page up: HTML Version of the book
  
next page: 22.3.11. syntax error at /dev/null line 1, near "line arguments:"

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:

  • prev: 22.3.9. Callback called exit
  • Table of Contents
  • next: 22.3.11. syntax error at /dev/null line 1, near "line arguments:"







TOP
previous page: 22.3.9. Callback called exit
  
page up: HTML Version of the book
  
next page: 22.3.11. syntax error at /dev/null line 1, near "line arguments:"


Menu

  • HTML Book
  • PDF Book
  • Download Code
  • Table of Contents
  • Errata
  • mod_perl2 User's Guide
  • Sitemap

Search


Add to Google




Creative Commons License


Written by
Eric Cholet (Logilune) and
Stas Bekman (StasoSphere & Free Books).


[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007 StasoSphere.com