Memory allocation

Peter Hansen peter at engcorp.com
Mon Sep 22 14:20:22 EDT 2003


"Batista, Facundo" wrote:
> 
> How could I know how much memory uses an object?
> 
> Something like:
> 
> >> a = [66]
> >> memused(a)
> n

Can you provide more background on the specific problem you need
to solve, or are you looking for a very general solution?  In 
other words, do you just need to know how much memory a list, or
an integer uses up, or do you think you need a general-purpose
function which works with any object of any type.

And in the above example, would you be interested in the memory 
used by the integer 66, or the memory used by the list that contains 
a reference to that integer, or the combined total?

-Peter




More information about the Python-list mailing list