My issue occurs upon dereferencing the array. my @unfilteredOutput = @$outputRef;
That not (just) dereferencing the array, it is copying it. Effectively doubling your memory usage. So don't do that.
Anything you can do with @unfilteredOutput, you can do using $outputRef (using a slightly different syntax), without having to copy it first.
For example, you might iterate the elements of @unfilteredOutput like this:
$_ += $somevalue for @unfilteredOutput;
You could do the same thing without having duplicated the memory using: $outputRef->[ $_ ] += $someValue for 0 .. $#{ $outputRef };
And for your example, you can do: my $total_size = total_size( $outputRef );
Which will give you the same number, but will avoid having to duplicate it all first.
It seems like you need to read perldsc.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
|