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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.