in reply to Memory Error Printing Multiple Hashes Simultaneously
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Memory Error Printing Multiple Hashes Simultaneously
by Anonymous Monk on Jan 31, 2006 at 23:36 UTC | |
|
Re^2: Memory Error Printing Multiple Hashes Simultaneously
by BrowserUk (Patriarch) on Feb 01, 2006 at 09:35 UTC | |
by bernanke01 (Beadle) on Feb 01, 2006 at 18:14 UTC | |
|
Re^2: Memory Error Printing Multiple Hashes Simultaneously
by demerphq (Chancellor) on Feb 01, 2006 at 15:28 UTC | |
by bernanke01 (Beadle) on Feb 01, 2006 at 18:12 UTC | |
by demerphq (Chancellor) on Feb 01, 2006 at 19:10 UTC |