> I know that method lookups are cached,

I remembered hearing people talking about this. That was the only possible theory left.

> but I am quite certain (from the last time I read the documentation) that that cache is associated with the package STASH, rather than each object, since it logically applies to the class (package) and is shared between all objects of that class.

Cool, that's what I needed to know! :)

> Arrays in Perl do have considerably smaller overhead than hashes, although not a factor of 10.

I did some tests for different sizes, yes it's not that dramatic - a 50% win is a very optimistic scenario.°

> changing the internal representation to arrays and using constant to name the fields is likely to help.

Well it's not my project anyway and some of my colleagues have weird strategies when it comes to optimization.

Personally I'm thinking rather in O() categories, and 50% best case wouldn't convince me to refactor.

I'd rather give Toby's suggestion for Insight-Out-Objects a shot.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

°) Though I'm not too sure if I got the Powershell and Windows right, since all the spared "keys" should cause a bigger impact. Will need to dig deeper. :)


In reply to Re^4: Memory overhead of blessed hashes by LanX
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.