in reply to Re^6: Bizarre Array Size Disparity
in thread Bizarre Array Size Disparity
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Bizarre Array Size Disparity
by sunmaz (Novice) on May 17, 2012 at 19:00 UTC | |
|
Re^8: Bizarre Array Size Disparity
by sunmaz (Novice) on May 17, 2012 at 19:04 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 19:11 UTC | |
by sunmaz (Novice) on May 17, 2012 at 19:13 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 19:20 UTC |