Just in case, someone stumbles on this and wonders ...
@Dugal yes, I believe this is a memory leak in current versions of numpy (September 2012), which occurs when some Exceptions occur (see this and this ). Why does adding the gc call that @BiRico βfixedβ seem strange to me, although it should be done right after it appears? Maybe its weirdness in how python trash collects traces if someone knows about Exception handling and CPython Internals compiler assembly, I would be interested.
Temporary solution . This is not directly related to lists, but for example, most broadcast exceptions (an empty list does not match the size of the arrays, an empty array leads to the same leak. There is an exception that never appears). So, as a workaround, you should probably first check to see if the shape is correct (if you do this a lot, otherwise I would not really worry, this only seeps in a small line if I understood correctly).
FIXED: This issue will be fixed with numpy 1.7.
seberg
source share