[issue14596] struct.unpack memory leak

Serhiy Storchaka report at bugs.python.org
Sat Jun 23 14:47:05 CEST 2012


Serhiy Storchaka <storchaka at gmail.com> added the comment:

Now internal representation of Struct with small format string may
consume unexpectedly large memory and this representation may be
invisible cached. With patch you can get large internal representation
only for large format strings. It is expected.

And how about struct_sizeof.patch? Now sys.getsizeof() returns wrong
result for Struct:

28
>>> sys.getsizeof(struct.Struct('100B'))
28

The patch (it compatible with both Struct representations) fixes it:

52
>>> sys.getsizeof(struct.Struct('100B'))
1240

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14596>
_______________________________________


More information about the Python-bugs-list mailing list