You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Aleksandr Guidrevitch <pi...@tut.by> on 2003/07/23 23:05:18 UTC

Leackage prevention

Hi, All


I'm a kind of impatient person, so I've looked though the docs on
mod_perl, but haven't figured out some issues :). Probably this is
mentionned somewhere in the docs, can someone point me to this doc ?

Is there any way to completely avoid memory leackages while running 
mod_perl ? Would undef'ing a variable help here ? How perl garbage 
collector can be forced to free allocated memory ? I think that a little 
overhead brought by memory allocations will save many calcs involved by 
use MaxRequestsPerChild or size-controlling modules.

Any thoughts ?

Sincerely
Alex




Re: Leackage prevention

Posted by Aleksandr Guidrevitch <pi...@tut.by>.
Thank you, I've got the idea

Alex

Perrin Harkins wrote:
> You can't force it.  It does try to free unused memory though.  You can
> read a bit more here:
> http://perlmonks.org/index.pl?node_id=267280






Re: Leackage prevention

Posted by Perrin Harkins <pe...@elem.com>.
On Wed, 2003-07-23 at 17:05, Aleksandr Guidrevitch wrote:
> Is there any way to completely avoid memory leackages while running 
> mod_perl ?

Don't confuse memory leakage with size increase.  Perl programs in any
environment tend to grow over time as a result of the work they are
doing.  Calling it a leak implies that the memory is somehow being lost
in a way that makes it impossible to reclaim for future use during the
life of the process.  Usually the memory is being used, not leaked.

>  Would undef'ing a variable help here ?

It could.  That would allow the memory for that variable to be used
elsewhere in your program.  It could hurt performance though if you
undef variables that you reuse frequently.  Generally you would only
want to do this with variables that might occasionally hold a large
amount of data for a short period. 

> How perl garbage 
> collector can be forced to free allocated memory ?

You can't force it.  It does try to free unused memory though.  You can
read a bit more here:
http://perlmonks.org/index.pl?node_id=267280

> I think that a little 
> overhead brought by memory allocations will save many calcs involved by 
> use MaxRequestsPerChild or size-controlling modules.

My advice to you is to write clean code and use Apache::SizeLimit.  You
will never get rid of all growth.  For one thing, there is C code used
by most people (DBI, Storable, etc.) that could also be causing growth.

- Perrin