[New-bugs-announce] [issue14596] struct.unpack memory leak
report at bugs.python.org
Mon Apr 16 14:10:12 CEST 2012
New submission from Robert Elsner <robert.elsner2 at googlemail.com>:
When unpacking multiple files with _variable_ length, struct unpack leaks massive amounts of memory. The corresponding functions from numpy (fromfile) or the array (fromfile) standard lib module behave as expected.
I prepared a minimal testcase illustrating the problem on
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2
This is a severe limitation when reading big files where performance is critical. The struct.Struct class does not display this behavior. Note that the variable length of the buffer is necessary to reproduce the problem (as is usually the case with real data files).
I suspect this is due to some internal buffer in the struct module not being freed after use.
I did not test on later Python versions, but could not find a related bug in the tracker.
components: Library (Lib)
title: struct.unpack memory leak
versions: Python 2.6
Added file: http://bugs.python.org/file25238/unpack_memory_leak.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce