in reply to Re^5: Bizarre Array Size Disparity
in thread Bizarre Array Size Disparity

The population of the array is done from an extrinsic library and returns and array reference. It should be considered an inscrutable process. I have sufficient memory for that. My issue occurs upon dereferencing the array.
my @unfilteredOutput = @$outputRef; ... my $total_size = total_size(\@unfilteredOutput); print PROGRESS "SIZE OF UNFILTERED OUT FROM INFO FILTER: ".$total_ +size;
$total_size is too large. I know that isn't much help...sorry...

Replies are listed 'Best First'.
Re^7: Bizarre Array Size Disparity
by BrowserUk (Patriarch) on May 17, 2012 at 18:56 UTC
    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".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      I don't know why this didn't occur to me. Thanks!
      Can I tie and pack the reference directly to further minimize memory usage?
        Can I tie and pack the reference directly to further minimize memory usage?

        I don't know what you mean by that?


        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".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?