>>>>> "TM" == Tom Metro <[email protected]> writes:
TM> Conor Walsh wrote: >> You can trap OOM if your Perl is compiled to use $^M... TM> http://perldoc.perl.org/perlvar.html TM> $^M TM> By default, running out of memory is an untrappable, fatal error. TM> However, if suitably built, Perl can use the contents of $^M as an TM> emergency memory pool after die()ing. Suppose that your Perl were TM> compiled with -DPERL_EMERGENCY_SBRK and used Perl's malloc. Then TM> 1. $^M = 'a' x (1 << 16); TM> would allocate a 64K buffer for use in an emergency. TM> Interesting. That explanation seems to leave some things unexplained. So TM> presumably with -DPERL_EMERGENCY_SBRK and space allocated to $^M, if an TM> OOM happened you could trap it with $SIG{__DIE__} and have enough heap TM> memory to handle any incidental allocations needed by your signal handler? i am not sure if that would trigger a die signal. but maybe wrapping the entire top level in an eval block would trap it and use the ram in $^M and you could dump a stack trace (cluck) from that. i would allocate a lot more than 64k for this. maybe 1MB would do it. it would be easy enough to test with a short program that allocates lots of ram under a low ulimit. you could see whether the signal or eval works and even estimate how much ram it needs for the cluck call to work. once you get that working, it should be easy to fit it into you real code and see a stack trace where it really is dying. uri -- Uri Guttman ------ [email protected] -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

