Hello,
I have the following code, where I noticed a memory leak with +=, but not with + alone. import numpy
m=numpy.matrix(numpy.ones((23,23)))
for i in range(10000000): m+=0.0 # keeps growing in memory # m=m+0.0 # is stable in memory
My version of python is 2.5, numpy 1.3.0, but it also causes memory build-up in 2.6 with numpy 1.4.0, as distributed by the Enthought Python Distribution.
It's easy to work around, but could cause someone some problems. Anyone else get this?
bb
On Fri, May 14, 2010 at 2:43 PM, Brian Blais bblais@bryant.edu wrote:
Hello,
I have the following code, where I noticed a memory leak with +=, but not with + alone. import numpy
m=numpy.matrix(numpy.ones((23,23)))
for i in range(10000000): m+=0.0 # keeps growing in memory # m=m+0.0 # is stable in memory
My version of python is 2.5, numpy 1.3.0, but it also causes memory build-up in 2.6 with numpy 1.4.0, as distributed by the Enthought Python Distribution.
It's easy to work around, but could cause someone some problems. Anyone else get this?
I get it also with python 2.5 numpy 1.4.0
Who owns the data ?
m=np.matrix(np.ones((3,3))) m.flags
C_CONTIGUOUS : True F_CONTIGUOUS : False OWNDATA : True WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False
m+=0 m.flags
C_CONTIGUOUS : True F_CONTIGUOUS : False OWNDATA : False <- GONE WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False
Josef
bb
-- Brian Blais bblais@bryant.edu http://web.bryant.edu/~bblais http://bblais.blogspot.com/
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Fri, May 14, 2010 at 3:26 PM, josef.pktd@gmail.com wrote:
On Fri, May 14, 2010 at 2:43 PM, Brian Blais bblais@bryant.edu wrote:
Hello,
I have the following code, where I noticed a memory leak with +=, but not with + alone. import numpy
m=numpy.matrix(numpy.ones((23,23)))
for i in range(10000000): m+=0.0 # keeps growing in memory # m=m+0.0 # is stable in memory
My version of python is 2.5, numpy 1.3.0, but it also causes memory build-up in 2.6 with numpy 1.4.0, as distributed by the Enthought Python Distribution.
It's easy to work around, but could cause someone some problems. Anyone else get this?
I get it also with python 2.5 numpy 1.4.0
Who owns the data ?
m=np.matrix(np.ones((3,3))) m.flags
C_CONTIGUOUS : True F_CONTIGUOUS : False OWNDATA : True WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False
m+=0 m.flags
C_CONTIGUOUS : True F_CONTIGUOUS : False OWNDATA : False <- GONE WRITEABLE : True ALIGNED : True UPDATEIFCOPY : False
Josef
Maybe it's not a "true" memory leak, my python process eventually garbage collected the extra memory that was built up.
Josef
bb
-- Brian Blais bblais@bryant.edu http://web.bryant.edu/~bblais http://bblais.blogspot.com/
NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On May 14, 2010, at 16:03 , josef.pktd@gmail.com wrote:
On Fri, May 14, 2010 at 3:26 PM, josef.pktd@gmail.com wrote:
On Fri, May 14, 2010 at 2:43 PM, Brian Blais bblais@bryant.edu wrote:
Hello,
I have the following code, where I noticed a memory leak with +=, but not with + alone. import numpy
m=numpy.matrix(numpy.ones((23,23)))
for i in range(10000000): m+=0.0 # keeps growing in memory # m=m+0.0 # is stable in memory
Maybe it's not a "true" memory leak, my python process eventually garbage collected the extra memory that was built up.
It crashed a simulator of mine (at least in Windows), until I figured out the workaround, so I would consider it a leak. :) it certainly shouldn't grow like that. if anything m=m+0.0 should chew of *more* memory than m+=0.0.
bb