The output I get is 

used memory = 0
used memory = 0
used memory = 0
used memory = 0
used memory = 0


I'm interested in how many leaks are possible in mod_perl
though because my mod_perl processes are getting bigger
with time -- about 200 requests is making the process
fatter by 1mb on the average.  I'm watching to see if
they will max out around the current level of 10 mb per child.



On Thu, Dec 07, 2000 at 07:53:16PM +0300, Ivan E. Panchenko wrote:
> 
> 
> Today I discovered a strange behaiviour of perl, 
> and I wonder if anybody can tell me what to do with it.
> 
> The matter is that perl DOES NOT REUSE MEMORY allocated for 
> intermediate calculation results. This is specially harmful to
> data-intensive modperl applications where one perl process processes
> many queries and can leak great amount of memory.
> 
> The example is below:
> 
> use BSD::Resource; 
> my $cc = 'a' x 20000000 ;        # alocates 20Mb for the right part and
>                                # 20Mb for $a
> &p;
> { my $a = $cc.'x';             # allocates 20 more Mb for right part
>                                # and 20 for a
> &p;
>   undef $a;                    # deallocates $a
> }
> &p;
> { my $b = $cc.'y';             # allocates 20 more Mb for right part
>                                # and reuses deallocated 20Mb for b 
>  &p;
>   undef $b; 
> }
> &p;
> 
> sub p { 
>   print STDERR "used memory = ".(BSD::Resource::getrusage)[2]."\n"
> }
> 
> # end of example.
> Output:
> used memory = 40772
> used memory = 79804
> used memory = 80068
> used memory = 99676
> used memory = 99700
> ##
> Here I used BSD:Resource to measure consumed memory. Its result seems to
> be correlated with the amount of memory taken by the process from the OS.
> #
> 
> This was checked on FreeBSD 3.4 and 4.2 ; and perl5.00405 5.00503 .
> Same things where noticed on Linux and probably on Solaris too.
> 
>               Ivan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to