[issue14596] struct.unpack memory leak

Mark Dickinson report at bugs.python.org
Mon Apr 16 14:25:08 CEST 2012

Mark Dickinson <dickinsm at gmail.com> added the comment:

I suspect that this is due to the struct module cache, which caches Struct instances corresponding to formats used.  If that's true, there's no real leak as such.

As a test, what happens if you increase your xrange(30) to xrange(300)?  (And perhaps decrease the size of the struct itself a bit to compensate).  You should see that memory usage stays constant after the first ~100 runs.

Using Struct directly is a good workaround if this is a problem.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list