Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Perl "Out of memory!" Error signal backtrace

by OnEhIppY (Initiate)
on Nov 13, 2021 at 05:15 UTC ( [id://11138768]=perlquestion: print w/replies, xml ) Need Help??

OnEhIppY has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to get a Signal call for the Out of memory! call within a perl script?

Somewhere deep within the thread it gives me that message, yet there seems no way to catch that call, to do a traceback to the whole call structure, to see where things go wrong, like the warn and die have a signal, yet these are not triggered by this particular one.

There are some kill signals about memory, but these seem neither to be triggered.

Anyone an idea how to trace the code point?
  • Comment on Perl "Out of memory!" Error signal backtrace

Replies are listed 'Best First'.
Re: Perl "Out of memory!" Error signal backtrace
by dave_the_m (Monsignor) on Nov 13, 2021 at 08:58 UTC
    The problem is that once the perl interpreter has exhausted all memory, there's very little it can do. There is a reserved fixed buffer to allow it to display the the OOM error itself, but doing anything complex like displaying a Carp::confess()-like stack backtrace would require many memory allocations to generate the display, all of which would themselves fail.


Re: Perl "Out of memory!" Error signal backtrace
by eyepopslikeamosquito (Archbishop) on Nov 13, 2021 at 08:38 UTC
      Just noticed this today, but Test::Valgrind is available as a package in Ubuntu (libtest-valgrind-perl). Valgrind is mentioned in the target page link by eyepopslikeamosquito, but I am pointing out it may offer an expedient way to research the issue on your system.
Re: Perl "Out of memory!" Error signal backtrace (updated)
by LanX (Saint) on Nov 13, 2021 at 05:37 UTC
    I'd say you need to track the growth of your memory consumption. Not sure what the codepoint can tell you.

    You probably have a memory leak due to recursive data structures.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery


    according to splain -v it's non-trappable

    Well ...

    ... probably the trace options of the debugger can help?

    If you log them to a file, you should see where they stop.

Re: Perl "Out of memory!" Error signal backtrace
by perlfan (Vicar) on Nov 13, 2021 at 16:54 UTC
    > Somewhere deep within the thread

    If you reproduce it, post the code here. I am guessing you're making some wrong assumption about threads and how they work in perl; without knowing what you're doing, I can blindly suggest: 1) get it working serially, and 2) if you need to workshare, use fork or better, Parallel::ForkManager. Also, if you're reading in a entire 1 TB file or grabbing a billion rows from mysqld, then there are better ways to do it.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11138768]
Approved by LanX
Front-paged by kcott
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-21 21:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found