[Python-Dev] tracking memory consumption
Martin von Loewis
loewis@informatik.hu-berlin.de
Tue, 29 Feb 2000 16:43:11 +0100
> > In PR#214 Martin v. Loewis suggests a sizeof function as result of
> > request to python-help. I've followed the thread silently until now.
>
> For such basic computations of the native objects sizes, struct.calcsize
> is your friend.
Unfortunately, it does not work in the general case, or I'm missing
something: Given
>>> a={}
>>> for i in range(1,10):
... a[i]=i*i
...
how exactly do you find out the size occupied by a? I don't want to
count the size of the keys and values themselves - just the memory
used by the storage of the references to the keys and the values.
Regards,
Martin