Hi Chris,
No contribution from me as regards a solution - just a couple of follow-up questions (mainly for my own edification).

The call of exit() rather than die() means that, for example, running a Perl REPL interactive shell for PDL can crash without recovery

From that, I deduce that when an OOM error occurs, the OS tells perl it has to exit(), and perl obeys.
However, I had always assumed that when such an error occurred, the OS would simply kill the perl process - no opportunity for perl to perform an exit() ... or to perform anything else, for that matter. Is my assumption incorrect ? (They often are, of course.)

If perl does, in fact, exit() when an OOM error occurs, then it will first execute any END{} blocks.
I don't think that helps *you* in any way, but it would enable one to verify that an OOM error causes perl to exit(). I tried to test this out myself by writing a script with an END{} block that printed something to STDOUT, and having that script generate an OOM error. Only problem was that I couldn't find a way of generating the OOM error :-(
So that's my second question to the assembled monks: "What's the surefire way of generating an OOM error in a perl script ?"

Cheers,
Rob

In reply to Re: die rather than exit on out-of-memory failure? by syphilis
in thread die rather than exit on out-of-memory failure? by chm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.