size of an object? 
Author Message
 size of an object?

We have a structure consisting of a reference to a hash, whose values
can be references to hashes, references to arrays, or scalars, and
this follows down for some levels. (Is the object that constructs the
module XML::Simple if you know it.)

Is there a way to know its size in memory?

-- fxn



Fri, 26 Mar 2004 21:14:15 GMT  
 size of an object?
[Posted and mailed]



Quote:
> We have a structure consisting of a reference to a hash, whose values
> can be references to hashes, references to arrays, or scalars, and
> this follows down for some levels. (Is the object that constructs the
> module XML::Simple if you know it.)

> Is there a way to know its size in memory?

Are you just looking for a rough guess?  This usually works:

        1. Note process size.
        2. Create lots of instances of the structure.
           If you copy, beware of deep-copy of references issues
        3. Note process size.
        4. Divide the difference in the process sizes by the number of
           copies.  There's your rough estimate.

Remember that perl will grab memory in "chunks" which will exceed what
it actually needs.  Do this a couple of times for different values
of "lots" to smooth out your estimate.

--
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*

"If you rush a Miracle Man,     for details, see http://geeksalad.org    
        you get rotten Miracles." --Miracle Max, The Princess Bride



Sat, 27 Mar 2004 04:42:29 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Measuring size of a object

2. Getting requested size of an object

3. How to get the array size with an object ?

4. CGI.pm Bug: file upload file size mismatch when file size is close to buffer size

5. getting object size?

6. Idea: Term::Size, simple way to get terminal size

7. Can't get size value back when using $ftp->size

8. Differences in the file size reported by Net::FTP->size and ls -l

9. Free: Make 3D scan from real object to virtual object

10. Scripting for both object and non-object (fwd)

11. Scripting for both object and non-object

12. Can I put an object in an object?

 

 
Powered by phpBB® Forum Software