I need to understand how much memory is used for what in perl
Look at Devel::Size.
To the larger question, I've had some luck optimizing a large data structure by storing records using pack/unpack. I.e. rather than a hash-of-hash, I switched to hash-of-packed-array. In this case, all the data elements were just integers, so they packed down pretty well. On any particular run, I only needed some of them, so the cost of unpacking the ones I needed to access was small relative to the savings of keeping the entire data set in memory. (Plus, I could save/load the entire packed structure using Storable, too.)
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re: Optimizing Memory consumption
by xdg
in thread Optimizing Memory consumption
by PerlingTheUK
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |