in reply to Memory usage by perl application
See illguts. Basically, every scalar value (SV in internal-speak) in Perl takes up 16 bytes plus whatever payload (think "string length") is stored in the value. Hash keys are also refcounted, maybe they also are SVs. So, if you store very many, relatively small items in your hash, as keys and values, your memory needs might be up to 16 or 32 times the size of the input file, at least if the keys are all different.
You can easily move your hash to disk by using DB_File or one of the other tied hash implementation (SDBM_File, GDBM_File). This means your hash access is slower, but you are only limited by disk space, not core memory.
Alternatively, maybe you can easily save memory by simply not reading the whole file into a hash, by changing to a different algorithm. But for that, we will need to see your data and code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Memory usage by perl application
by magarwal (Novice) on Dec 22, 2010 at 17:31 UTC | |
by Corion (Patriarch) on Dec 22, 2010 at 18:01 UTC |