in reply to How to capture out of memory excpetion in perl?

I cannot find an old discussion about the misterious $^M special variable but I found this:
$^M By default, running out of memory is an untrappable, fatal error. However, if suitably built, Perl can use the contents of $^M as an eme +rgency memory pool after die()ing. Suppose that your Perl were compiled with -DPERL_EMERGENCY_SBRK and u +sed Perl's malloc. Then $^M = 'a' x (1 << 16); would allocate a 64K buffer for use in an emergency. See the INSTALL file in the Perl distribution for information on how t +o add custom C compilation flags when compiling perl. To discourage casual use of this advanced feature, there is no English + long name for this variable.
ah ok is this: 287850

Hope some sage can tell how to use this!!
HTH Lor*

Replies are listed 'Best First'.
Re^2: How to capture out of memory excpetion in perl?
by educated_foo (Vicar) on Apr 24, 2008 at 02:19 UTC
    In my experience with similar things, the idea is that your code gets called (via signal or callback) when the program dips into the emergency pool ($^M). It should then immediately rummage around and try to free stuff, then try to reallocate the emergency pool. If it fails, then you're probably doomed.

    Unfortunately, I don't see a relevant callback for $^M. If so, then there's no way to tell when $^M has been used, and I don't see how it can be useful.