The long time mythical
use less qw(memory);
pragma was always intended to address issues like that. It would be
fairly straightforward to implement (set a flag like use strict and
check it wherever memory could usefully be freed).
Tim.
On Sat, Dec 09, 2000 at 07:53:38PM +0300, Ivan E. Panchenko wrote:
>
> No, i did not mean freeing memory from lexicals. I meant the memory
> allocated for the temporary results, such as
>
> my $a = 'x' x 1000000
>
> Here perl allocates 1M for $a and 1M for evaluating the right part,
> after that it is possible to undef $a and reuse its memory (1M),
> but the right part memory (one more 1M) can be used nowhere except the
> same line of code.
>
> This is strange. I understand that it can be an optimization trick,
> but when you frequently operate with megabytes, this becomes a
> pleasant feature which looks and behaves like a memory leak :)
>
> Ivan
>
> > > 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.
> >
> > This is known and it's not really a leak. Perl knows about that memory
> > and does re-use it, the next time it needs that lexical variable. It's a
> > performance optimization. Try running your code multiple times and you
> > should see memory stay at the same level after the first run.
> >
> > There has been discussion about this on the mailing list which you can
> > find in the archives. There has also been talk about changing this
> > behavior for mod_perl 2, which Doug is working on.
> >
> > Anyway, if you just want the memory back, undef your lexicals after you
> > finish with them.
> >
> > - Perrin
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]