And here is a speedy reply to the perlbug by Gisle Aas:
This is not a memory leak. The reason perl allocates memory during printing is that it converts all the 0 values in the hashes to strings + and stores these. This upgrades your SvIV structs containing 0 into the much larger SvPV structs containing both 0 and "0" (see [1]). --Gisle [1] http://search.cpan.org/src/GAAS/illguts-0.09/index.html#sviv
I won't claim to fully understand, but I guess it means that Perl is changing the hash from storing simply integers to storing both integers & strings during printing. And this change occurs on the hash itself, increasing memory usage. Printing without string interpolation (or join prevents this "upgrading" and thus prevents all the memory usage. I guess it makes sense, but I'm just really surprised no one had come across this before!
In reply to Re: Memory Error Printing Multiple Hashes Simultaneously
by bernanke01
in thread Memory Error Printing Multiple Hashes Simultaneously
by bernanke01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |