[Numpy-discussion] Memory leak with matrices?

David Paul Reichert D.P.Reichert at sms.ed.ac.uk
Tue Mar 9 12:31:03 EST 2010


I've got two issues:

First, the following seems to cause a memory leak,
using numpy 1.3.0:

a = matrix(ones(1))

while True:
    a += 0

This only seems to happen when a is a matrix rather
than an array, and when the short hand '+=' is used.

Second, I'm not sure whether that's a bug or whether
I just don't understand what's going on, but when a is a column
array, (e.g. a = ones((10, 1))), then

a -= a[0,:]

only subtracts from a[0, 0], whereas not using the short hand
or using something else than a on the righthand side seems
to subtract from all rows as expected.

Thanks a lot,


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

More information about the NumPy-Discussion mailing list