Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Is there a way to find the size of a data structure?

by bsdz (Friar)
on May 16, 2005 at 11:14 UTC ( [id://457414]=note: print w/replies, xml ) Need Help??


in reply to Is there a way to find the size of a data structure?

You could use Storable, just freeze the structure in memory and print its length, i.e.
use Storable; my %a = ( 'a' => 'something..', 'b' => 'something else..', ) print length(Storable::freeze(\%a))."\n";
This will give you a "rough ball-park sizeof" without the memory overhead of using a module like Devel::Size :-)

Replies are listed 'Best First'.
Re^2: Is there a way to find the size of a data structure?
by dakkar (Hermit) on May 16, 2005 at 19:19 UTC

    Well, that would give the size of the Storable image of the data, not the live-in-RAM size... and I think the OP intended the latter.

    So, for the OP: use Devel::Size, or study the sources...

    -- 
            dakkar - Mobilis in mobile
    

    Most of my code is tested...

    Perl is strongly typed, it just has very few types (Dan)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-26 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found