in reply to Re^2: Bizarre Array Size Disparity
in thread Bizarre Array Size Disparity
I desperately need to reduce the memory it is using. ... I cannot easily change how it is constructed.
If you cannot change how it is constructed, you cannot reduce the memory that will be used as it is constructed.
You could reduce it after the fact by packing the doubles into a string:
perl -MDevel::Size=total_size -le"@a= map rand(),1..1e6; print total_size \@a; $b=pack'd*', @a; prin +t total_size( $b )" 40000176 8000056
That's a 5 to 1 reduction. It will free up memory for other things if you then undef'd the array, but it usually won't release memory back to the OS.
And the individual elements can be accessed and modified use substr in conjunction with pack & unpack. The penalty is loops run more slowly. PDL would be much quicker.
It would be much better if you could avoid the creation of the array in the first place
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Bizarre Array Size Disparity
by sunmaz (Novice) on May 17, 2012 at 18:15 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 18:23 UTC | |
by sunmaz (Novice) on May 17, 2012 at 18:29 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 18:56 UTC | |
by sunmaz (Novice) on May 17, 2012 at 19:04 UTC | |
| |
by sunmaz (Novice) on May 17, 2012 at 19:00 UTC | |
|
Re^4: Bizarre Array Size Disparity
by sunmaz (Novice) on May 17, 2012 at 18:08 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 18:12 UTC | |
by sunmaz (Novice) on May 17, 2012 at 18:19 UTC |