Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Memory overhead of blessed hashes

by tobyink (Canon)
on Feb 09, 2021 at 17:05 UTC ( [id://11128137]=note: print w/replies, xml ) Need Help??


in reply to Memory overhead of blessed hashes

Blessed arrayrefs will save a bit of memory. If the data being stored is simple enough that it can be serialized into strings, blessed references to strings are are also possible. They are likely to be the most memory-efficient representation of objects, but they can be a pain if your objects aren't very simple. Inside-out objects are also pretty memory-efficient if you have lots of objects but only a few fields, because it's one hash per field instead of one hash per object.

Do check whether it's really the objects causing the issue though — it might be something like a memory leak caused by more references to the objects than expected. (Cyclical references; objects getting closed over by coderefs; global variables holding references to the objects.)

Replies are listed 'Best First'.
Re^2: Memory overhead of blessed hashes
by LanX (Saint) on Feb 09, 2021 at 17:35 UTC
    I agree about the memory leak, alas not my code.

    > Inside-out objects are also pretty memory-efficient if you have lots of objects but only a few fields, because it's one hash per field instead of one hash per object.

    Good point! ++

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11128137]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found