perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donovan Allen <>
Subject Re: memory usage
Date Thu, 18 Dec 2003 22:42:40 GMT
Hans de Groot wrote:

>I usally create pages that look like this:
>some perl here
>store all output in $ouput
>use http_headers_out followed with and exit() if I need to redirect.
Unless you need the "local" scope of the [* *] blocks, you might try the 
[- -] instead and see if that fixes your problem.  Change it on one page 
and repeatedly call that page while watching the memory use.

I have never had memory problems using [* *], but that may be because I 
only use them for loops around html output.  I generally stick with [- 
-] blocks.

>I do have one problem. My apache processes take a lot of memory.
Apache + any mod_perl tend to take a lot of memory anyway, however some 
of it is shared between processes.

>Every request of a page it grows in size. How do I prevent, or minimize the loss of memory?
One other thing to be aware of is that if you are using modules, the 
variables in the module need to have proper scope (such as my() in 
functions and methods), otherwise you will get what "appears" to be a 
memory leak.

Getting all the "use" lines from your code and putting them into one 
document where you can comment them out, refresh the page, and check 
memory is a dirty but quick was to isolate a module that has not 
declared proper variable scope.

It is possible that things have changed, but as I recall default perl 
installs rarely (if ever?) use versions of malloc() that allow 
deallocation of used memory while running (providing that your OS even 
supplies one).  Your best tactic in general is to use memory carefully 
in practice and find what is causing the memory consumption and fixing it.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message