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.
In reply to Re^3: Out of Memory Error -- Possible Leak?
by BrowserUk
in thread Out of Memory Error -- Possible Leak?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |