Author Robert.Elsner
Recipients Robert.Elsner
Date 2012-04-16.12:10:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.
Date User Action Args
2012-04-16 12:10:12Robert.Elsnersetrecipients: + Robert.Elsner
2012-04-16 12:10:12Robert.Elsnersetmessageid: <>
2012-04-16 12:10:11Robert.Elsnerlinkissue14596 messages
2012-04-16 12:10:11Robert.Elsnercreate