in reply to Re^2: Out of Memory Error -- Possible Leak?
in thread Out of Memory Error -- Possible Leak?
I'm really confuzzled as to why this:
foreach my $value ( @$subarray ) {would eat up memory.
That line expands the contents of the array into a list (Ie. On Perls' stack). If the subarray pointed by $subarray is large, it will consume a large amount of memory to do that.
You can avoid that by indexing the array, rather than aliasing it's elements. Eg.
for my $index ( 0 .. $#$subarray ) { my $value = $subarray->[ $index ]; ... }
Or, if you need to modify the elements, substitue $subarray->[ $index ] wherever you are currently using $value.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.