I'm not sure exactly what your situation is, so a lot of this is probably irrelevant:

In my experience, using objects versus unblessed hashes can cause things to be slower (CPU overhead of blessing them) but doesn't add much memory overhead.

In some situations it might make more sense (financially) to add more RAM instead of spending time reworking the code.

It's probably not relevant here if you're using objects normally, but with deeply-nested hashes (when doing aggregation, for example) you can save a bit of memory by flattening the hash and concatenating the keys with $;.

If you're pulling data from a database, keeping the data "on the C side" can save a lot of memory. At least by default with DBD::mysql, it will download the data all at once into C structures, which uses a lot less memory than the same data "inflated" into Perl structures. So for example when aggregating (sum, avg, ...), if you can fetch individual rows instead of all at once, it can save memory. Depending on how (elegant, simple) your code is, it can be challenging to refactor it to do this, though.

End of memory dump. :)


In reply to Re: Memory overhead of blessed hashes by ForgotPasswordAgain
in thread Memory overhead of blessed hashes by LanX

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.