On Thu, Dec 10, 2009 at 11:28 AM, E R <pc88m...@gmail.com> wrote:
> Hi,
>
> I have a problem where a mod_perl handler will allocate a lot of
> memory when processing a request, and this causes Apache to kill the
> child due to exceeding the configure child size limit.
>
> Are there any special techniques people use to avoid this situation?
> Does SizeLimit count actual memory used or does it just look at the
> process size?

You can make sure the variables that the memory was malloc'd for have
gone out of scope, and there are not trailing references to them.
Perl will then reuse that memory.  Occasionaly Perl will free memory
it's not using, but why, where and when can be hard to determine.
It's not always as clear cut as undef'ing the variable.

In terms of managing memory in your mod_perl process you can use any
of the standard techniques:

  * change/fix the code (fix memory leak, Tie structure to filesystem/db, ...)
  * recycle your children after N number of request are completed
  * offload the memory intensive work into a different process space
(another instance of Apache/mod_perl or even just Perl)
  * use a system set resource limit (not so good because it can kill
the proc mid-request)
  * Apache2::SizeLimit (kill the proc after it's done serving the
request when it grows too big)

These were off the top of my head.  THere may be other techniques I missed.

-wjt

Reply via email to