You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ken Simpson <ks...@ghpbjymdczr.mailchannels.com> on 2005/01/26 19:49:20 UTC

Debugging Out of Memory Errors

A module I wrote is somehow running out of memory and I need to find
out why and where the problem is occurring.  Searching through the
archives, I discovered that in mod_perl 1.0 you could set the
Apache::Debug level to 4:

 use Apache::Debug level => 4;
 (see the mod_perl book: http://modperlbook.org/html/ch22_03.html)

Doing this would cause a special memory allocator to be used so that
Carp could print out a stack trace in the event of an out of memory
error.

Is there an equivalent in mod_perl?

Thanks,
Ken

-- 
MailChannels: Assured Messaging

--
Eliminate Critical False Positives
http://www.mailchannels.com
MailChannels Corporation
Suite 1600, 1188 West Georgia St.
Vancouver, BC, Canada

Ken Simpson, CEO
+1-604-729-1741

Sent by MailChannels: http://www.mailchannels.com

Re: Debugging Out of Memory Errors

Posted by Stas Bekman <st...@stason.org>.
Ken Simpson wrote:
>>>Is there an equivalent in mod_perl 2?
>>
>>I guess it wasn't on the todo list, so we have missed it while porting mp1 
>>core modules to mp2 It looks like it's trivial to port it to mp2. Feel 
>>free to port that and post a patch to include it in the mp2 core, or 
>>someone will do that later.
> 
> 
> I won't have time to do that work right now, but I'll consider it for
> a rainy day. 

You could probably also try to set $^M. Or you can use Apache::Resource 
directly.

> Another question then: Is there a default pool size that
> is used to allocate the Perl interpreter in a mod_perl process?

memory pools are not used in the perl interpreter (unless you use win32).

But see the docs for $^M in perlvar.pod.

Recently I've learned a nice trick to handle this problem though. If you 
don't use (Apache|BSD)::Resource you can ulimit(1) max memory in your 
shell. It works perfectly.

> If so, can that size be increased? From tracing, it seems the out of
> memory is happening while allocating a ~3MB string within my
> module. That doesn't seem very large, but I thought perhaps there's a
> default that I'm trampling on.

You should be able to reproduce this outside of modperl, in which case 
it'll qualify as a p5p question, where you will get a definitive answer 
from the perl core gurus :)


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: Debugging Out of Memory Errors

Posted by Ken Simpson <ks...@ghpbjymdczr.mailchannels.com>.
> >Is there an equivalent in mod_perl 2?
> 
> I guess it wasn't on the todo list, so we have missed it while porting mp1 
> core modules to mp2 It looks like it's trivial to port it to mp2. Feel 
> free to port that and post a patch to include it in the mp2 core, or 
> someone will do that later.

I won't have time to do that work right now, but I'll consider it for
a rainy day. Another question then: Is there a default pool size that
is used to allocate the Perl interpreter in a mod_perl process?

If so, can that size be increased? From tracing, it seems the out of
memory is happening while allocating a ~3MB string within my
module. That doesn't seem very large, but I thought perhaps there's a
default that I'm trampling on.

Thanks,
Ken

-- 
MailChannels: Assured Messaging

--
Eliminate Critical False Positives
http://www.mailchannels.com
MailChannels Corporation
Suite 1600, 1188 West Georgia St.
Vancouver, BC, Canada

Ken Simpson, CEO
+1-604-729-1741

Sent by MailChannels: http://www.mailchannels.com

Re: Debugging Out of Memory Errors

Posted by Stas Bekman <st...@stason.org>.
Ken Simpson wrote:
> A module I wrote is somehow running out of memory and I need to find
> out why and where the problem is occurring.  Searching through the
> archives, I discovered that in mod_perl 1.0 you could set the
> Apache::Debug level to 4:
> 
>  use Apache::Debug level => 4;
>  (see the mod_perl book: http://modperlbook.org/html/ch22_03.html)
> 
> Doing this would cause a special memory allocator to be used so that
> Carp could print out a stack trace in the event of an out of memory
> error.
> 
> Is there an equivalent in mod_perl 2?

I guess it wasn't on the todo list, so we have missed it while porting mp1 
core modules to mp2. It looks like it's trivial to port it to mp2. Feel 
free to port that and post a patch to include it in the mp2 core, or 
someone will do that later.

p.s. if there some other forgotten core bits that weren't ported please 
don't hesitate to mention those here.

Thanks.



-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: Debugging Out of Memory Errors

Posted by Ken Simpson <ks...@ghpbjymdczr.mailchannels.com>.
> Doing this would cause a special memory allocator to be used so that
> Carp could print out a stack trace in the event of an out of memory
> error.
> 
> Is there an equivalent in mod_perl?

Sorry -- I meant to say, "Is there an equivalent in mod_perl 2.0".

Thanks,
Ken

-- 
MailChannels: Assured Messaging

--
Eliminate Critical False Positives
http://www.mailchannels.com
MailChannels Corporation
Suite 1600, 1188 West Georgia St.
Vancouver, BC, Canada

Ken Simpson, CEO
+1-604-729-1741

Sent by MailChannels: http://www.mailchannels.com