in reply to Memory Efficient Alternatives to Hash of Array
Hm. presumably, you've only used <DATA> by way of example, as Perl would die just trying to load the script if it was 4GB+ in size.
Next. Why are you using a HoAs? On the basis of what you've posted, you have one key and one value per key, so wrapping that one value in an array just uses ~50% more memory than needed!
That is, changing:push @{ $hold{$elem[0]} }, $elem[1];
to $hold{ $elem[0] } = $elem[1]; would contain the same information but use 50% less memory to do so.
But either way, you've still got too much data to hold in memory on a 32-bit machine, and (on the basis of your script(s to date)), as the only reason for loading it is to sort it, you'd be far better off sorting it (the input file) externally and processing it line by line.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Memory Efficient Alternatives to Hash of Array
by tilly (Archbishop) on Dec 27, 2008 at 14:56 UTC | |
by eye (Chaplain) on Dec 27, 2008 at 20:19 UTC | |
by BrowserUk (Patriarch) on Dec 27, 2008 at 20:43 UTC | |
by tilly (Archbishop) on Dec 27, 2008 at 21:01 UTC | |
by neversaint (Deacon) on Dec 28, 2008 at 00:34 UTC | |
by BrowserUk (Patriarch) on Dec 28, 2008 at 01:05 UTC | |
|