On Wed, Oct 22, 2008 at 16:25, kenTk <[EMAIL PROTECTED]> wrote:
snip
> Thanks.
> My real application is in logging numerous sets of results each set
> saved in
> an anonymous array and those arrays referenced from a master array
> called @$arrayREFS
> When the results are read I clear the data using
> @{$arrayREFS[$index]}=();
> but am concerned that Perl's auto-creation of anonymous arrays may not
> reuse the memory that was used before and may grab new memory each
> time that one is created.
>
> What about
> $arrayREFS[$index]=undef;
> As an alternative way of deleting the data?
snip

That makes no difference.  Perl garbage collects all memory no longer
referenced by anything, but it does not necessarily return that memory
to the OS.  Perl will try to reuse unused memory it already has before
asking for more.  Do you have proof that the perl interpreter is
asking the OS for more memory, or are you merely concerned?  If it is
asking for memory when you think it shouldn't, then there could be a
few things going on:
1. you have references to the stuff you think should have been garbage
collected (possibly a circular reference* that won't be freed until
the program's end)
2. memory is fragmented in such a way that perl can't use the memory
it has to hold that data efficiently
3. unknown reason, put together a small test case that produces the
behavior and send it to perl5-porters and possibly this list.

* something like this:
    my $one;
    my $two = \$one;
    $one = \$two;
in order for this memory to be garbage collected you need to break the
cycle before $one and $two go out of scope.
-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to