Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6024651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:11:12+00:00 2026-05-23T04:11:12+00:00

tl;dr: How to dump a perl stack trace when a Perl httpd process runs

  • 0

tl;dr: How to dump a perl stack trace when a Perl httpd process runs out of memory.

We’ve got a mod_perl 2 server, Perl 5.8.8, RHEL 5.6, Linux 2.6.18.

Very occasionally and unpredictably, a child httpd process starts using up all available memory at an alarming rate. We’ve at least used BSD::Resource::setrlimit(RLIMIT_VMEM, …), so that the process dies with “Out of memory” before bringing down the server.

We don’t know where in the code this is happening, and it’s difficult to reproduce without hours of load testing.

What we’d really like is a way to get a Perl stack trace just before the process runs out of memory, so we know what code is causing this. Unfortunately, “Out of memory” is an untrappable error.

Here are the options I’m considering, each with their drawbacks:

1) Use the $^M emergency memory pool. Requires us to recompile perl with -DPERL_EMERGENCY_SBRK and -Dusemymalloc.

2) Put in tons of log statements, then analyze the logs to see where the process is stopping short.

3) Write an external script that constantly scans the pool of httpd processes, and if it sees one using a lot of memory, sends it a USR2 signal (which we’ve arranged to dump a stack trace).

4) Somehow have the process monitor its own memory continuously, and dump a stack trace when memory gets high but before the “Out of Memory” error.

Thanks!

Jon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:11:12+00:00Added an answer on May 23, 2026 at 4:11 am

    You might try using LD_PRELOAD to load a custom version of malloc/free. It should not be necessary to relink or recompile anything. Just set LD_PRELOAD to have a .so that has the same interface as malloc, and this preloaded version of malloc will be loaded instead of the normal system malloc when you run your executable. For instance, this is a common strategy for detecting memory errors with efence.

    I don’t think efence will work for you here as that is for detecting memory overwrites, not debugging out of memory (I don’t know what it does on OOM). I think what you might want to check out failmalloc. I have never used this one but it sounds like it might do what you want (I only skimmed the front page).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Cannot dump Stack Overflow XML file into SQL Server 2008. Could you please explain
Is there any way to dump the call stack in a running process in
I'm using a Perl script to dump the contents of a MySQL db. The
Is there anything in python that lets me dump out a random object in
Occasionally mod_perl apache process is marked defunct in top utility, that is becomes a
What's the best way to dump a MySQL table to a file in Perl?
I want to dump the output of Carp to a file handle in perl,
I'm stuck trying to figure out the perl regex to extract the following values:
% perl -Ilib -MDevel::Peek -le '$a=34567; $a=~s/...//; Dump($a)' SV = PV(0x8171048) at 0x8186f48 #
In Perl you can: print STDERR bla bla bla; ...and Apache will dump it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.