[issue2898] Add memory footprint query

Martin v. Löwis report at bugs.python.org
Sat May 17 16:11:33 CEST 2008


Martin v. Löwis <martin at v.loewis.de> added the comment:

> Proposals like this have been rejected in the past.  Memory consumption 
> is an evasive concept.  Lists over-allocate space

That issue is addressed in this patch.

> there are freelists, 

but they allocate just an upper bound.

> there are immortal objects, the python memory allocator may hang-on to 
> space thought to be available

These issues are orthogonal to the memory consumption of a single
object.

> the packing and alignment of structures 
> varies across implementations

This is addressed in the current patch.

> the system memory allocator may assign 
> much larger chunks than are needed for a single object

While true in general, this is not true in practice - in particular,
when objects get allocated through pymalloc.

> and the memory 
> may not be freed back to the system.  Because of these issues, it is 
> not that meaningful to say the object x consumes y bytes.

This is not true. It is meaningful to say that (and many that you
noted are independent from such a statement, as they say things for
the whole interpreter, not an individual object).

The patch meets a real need, and is the minimum amount of code that
actually *has* to be implemented in the virtual machine, to get
a reasonable analysis of the total memory consumption. Please be
practical here, not puristic.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2898>
__________________________________


More information about the Python-bugs-list mailing list