Finding the size of a rather complicated hash-structure

From: Fred (na_at_na.no)
Date: 10/27/04


Date: 27 Oct 2004 11:26:53 +0200

Hi group

Ok, so I've got a rather complicated hash-structure that I'd like to find
the size of. Size in consumed bytes of memory. Just because I'm curious.
And I've done the obligatory searches for finding sizes of stuff, and I'm
not much the wiser. Exept I've come to understand that there isn't any
bult-in functionality to do this for such structures.

So here I am then. Needing help!

My hash-structure looks something like this:

$tree = {
   <key> => {
     'name' => <str>,
     'file' => <str>,
     'architectures' => {
       <key> => {
         'name' => <str>,
         'file' => <str>,
         'components' => {
           <key> = {
             'name' => <str>,
             'lib' => <str>
           }
         }
       }
     }
   }
};

Actually it's much bigger, but this gives you a general idea of what it's
like. For each anonymous hash, the '<key>' have several elements,
typically around a hundred in $tree, one or two in
$tree->{<key>}->{'architectures'} and none or a couple in
$tree->{<key>}->{'architectures'}->{<key>}->{'components'}.

I suppose I could loop through tree, pushing name and file to an array,
looping through the architectures for each element in tree, and pushing
name and file to the same array, and doing the same with the components.
And then just flattening the array and use length(). But...that's kinda
dirty.....

(Not that I don't like my gals dirty...and perl's my bitch...so I guess I
might as well go for it...hehe! :-D )

But anyway...any good suggestions on how I can find out how many bytes of
memory my Frankenstein-hash is consuming, without writing a whole program
to find it? Or doing it the 'dirty' way?



Relevant Pages

  • Re: Low on Virtual Memory (Windows Server 2003)
    ... "Jaime Stuardo" wrote in message ... I have finally found why inetinfo was consuming a lot of memory.. ...
    (microsoft.public.windows.server.general)
  • Re: Too Many Processes
    ... you should have, according to your calculations? ... Maybe they're consuming just the right amount of memory and you need more ... I am a power user and in tech support, so I have a good understanding of ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Ever growing OWSTIMER.EXE
    ... email, some usage analysis once a night, the occasional backup, and the ... OWSTIMER just keeps consuming more and more RAM without ever dropping. ... The OWSTIMER.EXE is running the timer job of Sharepoint in a schedule. ... when it was running the job, it will consume a lot of memory. ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: VBA lookup into large database
    ... (I dont see why it should be consuming all available memory, ... for doing efficient exact match on sorted data? ... most used into a template of a sort and try to sort, ... but in VBA it consumes all available memory. ...
    (microsoft.public.excel.programming)
  • Re: Finding the size of a rather complicated hash-structure
    ... so I've got a rather complicated hash-structure that I'd like to find ... Size in consumed bytes of memory. ... Needing help! ... Write it to disk and look at the size of the file you create... ...
    (comp.lang.perl.misc)