[New-bugs-announce] [issue14596] struct.unpack memory leak

Robert Elsner 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)
files: unpack_memory_leak.py
messages: 158418
nosy: Robert.Elsner
priority: normal
severity: normal
status: open
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>
<http://bugs.python.org/issue14596>
_______________________________________


More information about the New-bugs-announce mailing list