[Numpy-discussion] Memory leak with matrices?
David Reichert
d.p.reichert at sms.ed.ac.uk
Tue Mar 9 13:15:06 EST 2010
Thanks for the reply.
Yes never mind the second issue, I had myself confused there.
Any comments on the memory leak?
On Tue, Mar 9, 2010 at 5:55 PM, <josef.pktd at gmail.com> wrote:
> On Tue, Mar 9, 2010 at 12:31 PM, David Paul Reichert
> <D.P.Reichert at sms.ed.ac.uk> wrote:
> > Hi,
> >
> > 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.
>
> this is because a[0,0] is set to zero after the first inplace
> subtraction, then zero is subtracted from all other rows
>
> >>> a = np.ones((10, 1))
> >>> a
> array([[ 1.],
> [ 1.],
> [ 1.],
> [ 1.],
> [ 1.],
> [ 1.],
> [ 1.],
> [ 1.],
> [ 1.],
> [ 1.]])
> >>> a += a[0,:]
> >>> a
> array([[ 2.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.]])
> >>> a -= a[0,:]
> >>> a
> array([[ 0.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.],
> [ 3.]])
>
> Josef
>
>
> >
> > Thanks a lot,
> >
> > David
> >
> > --
> > The University of Edinburgh is a charitable body, registered in
> > Scotland, with registration number SC005336.
> >
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100309/4d7b691c/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100309/4d7b691c/attachment.ksh>
More information about the NumPy-Discussion
mailing list