[Zope] Analyzing ZODB objects

Aurélien Campéas aurelien.aa at wanadoo.fr
Mon Oct 27 08:51:34 EST 2003


Le mer 22/10/2003 à 09:53, Bjorn Stabell a écrit :
> What is a good tool for analyzing the size of each object in the ZODB,
> pickled and unpacked in memory?  I'm using Zope 2.6.2.
> 
> With 62,214 objects in memory, the server uses 491MB of RAM.  That gives
> roughly 8kb per object, assuming other things aren't don't contribute to
> memory usage as well.  Is there any way to predict how much memory is
> going to be used?
> 
> Bye,

Counting elements of an object is a good start. Go and write some
depth-first object traversal code. This should be simple (in fact I've
already done it), if you do it recursively. 

Then, add some bits about the size of the objects you traverse (or you
count).

Basically, 
- you count 4 octets (32 bits ptr) for each object reference
encountered.
- for leaf objects, you can make good guesses about their sizes, e.g
some int may  be 4 octets, some string may be 2 octets (unicode ?) * len
(the string), etc... you get the idea
- for collection, repeat like above, recursively. The overhead for
lists/dictionaries must be so light that you just sum up the size of the
element's list, for dictionary you add the key size, ... etc..

Should be straightforward. Ah, don't follow weak pointers, if there are
any...

Regards,
Aurélien.


Q: What's the difference between a dead dog in the road and a dead
lawyer in the road? A: There are skid marks in front of the dog.




More information about the Zope mailing list