Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: How to Calculate Memory Needs?

by marcos (Scribe)
on Jun 18, 2002 at 09:15 UTC ( [id://175310]=note: print w/replies, xml ) Need Help??


in reply to Re: How to Calculate Memory Needs?
in thread How to Calculate Memory Needs?

I'm a bit late in this thread, but I have a similar problem: evaluate the size of a big hash that I have in memory.
I searched perlmonks for some clue on this issue, and I found this thread. I've read your ideas, and I found them very interesting. Anyway I came up with a different approach, and I'd like to share my idea with you so that you can give me feedback.
The idea is quite simple: I build the hash and then use Storable::freeze (see module Storable) to freeze it in memory, and then evaluate the length of it. I had this idea reading the man page of Storable module: here is an example from the man page:
use Storable qw(store retrieve freeze thaw dclone); %color = ('Blue' => 0.1, 'Red' => 0.8, 'Black' => 0, 'White' => 1); $str = freeze(\%color); printf "Serialization of %%color is %d bytes long.\n", length($str);

What do you think of this approach?

marcos

Replies are listed 'Best First'.
Re: Re: Re: How to Calculate Memory Needs?
by shotgunefx (Parson) on Jun 18, 2002 at 09:24 UTC
    I don't know either way, but I would think there is differences in the size of the in memory data structures and the stored versions. Even so, it would probably give you a good ball park figure though you would use more memory as you have both structures in memory.

    -Lee

    "To be civilized is to deny one's nature."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 07:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found