We've recently run into similar problems. Actually we moved a site from CGI to mod_perl using Apache::Registry. Anyway, some of our scripts caused the memory usage to skyrocket, thus triggering extreme swapping to disk, thus making the server unusable. We basically had to turn off mod_perl, then turn the scripts on one-by-one to find out which one was using the memory. When we found that, we manually looked through the script looking for suspicious bits of code. What we found was shocking (Disclaimer: I didn't write the code).

The guy before me had written a wrapper around DBI so he called functions like sql_arrayref() which would prepare, execute, and fetch all the rows returned into a huge array reference and return that. So yeah, he was copying to memory the entire result set. Obviously the solution in this case was to buffer the results and use them one by one.

So yeah, our solution was to find the scripts that were causing the problems and manually examine them for whacky memory usage.

Another problem we had was severe memory leaking in some scripts. So the memory wouldn't be released back to the OS (only back to the current httpd process if I understand correctly) after it used a whole bunch of memory. So if a few of these scripts were hit around the same time, the memory usage would skyrocket and the processes would still hang around, thus tying up the memory. Disclaimer: I'm not a sysadmin, but from what I gather, he temporarily reduced the time an http process could stick around, thus getting the memory back more quickly.

In reply to Re: Finding memory usage with Mod_Perl by saberworks
in thread Finding memory usage with Mod_Perl by Vaati

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.