Well, you can look at how
Apache::SizeLimit and
Apache::GTopLimit do it, but this is not likely to help you find leaks. Perl allocates memory in chunks, and it grabs a bit ahead of what it's actually using. The instruction executed just before a large gain in memory is not necessarilly the one responsible for most of that memory getting used.
The best way to find leaks is one that Matts described on the mod_perl list: run a section of code over and over, and watch the process with top to see if it grows over time. If you don't have any leaks, it will level off after maybe 100 or so requests and not grow anymore. If you do have leaks it will never stop growing.
Matt tested his code by throwing an exception to jump out of his program right after the section of code he was testing, and he would keep moving the exception deeper into the code until he found the leaky part. Tedious, but effective.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.