[Numpy-discussion] Memory leak

Aron Ahmadia aron@ahmadia....
Thu Jun 13 09:56:17 CDT 2013


Hi Petro,

What version of numpy are you running?

A


On Thu, Jun 13, 2013 at 3:50 PM, Pietro Bonfa' <pietro.bonfa@fis.unipr.it>wrote:

> Dear Numpy users,
>
> I have a memory leak in my code. A simple way to reproduce my problem is:
>
> import numpy
>
> class test():
>     def __init__(self):
>         pass
>
>     def t(self):
>         temp = numpy.zeros([200,100,100])
>         A = numpy.zeros([200], dtype = numpy.float)
>         for i in range(200):
>             A[i] = numpy.sum( temp[i].diagonal() )
>
>         return A
>
> a = test()
> c = [a.t() for i in range(100)]
>
> Running this script will require 1.5 Gb of memory since the 16 mb of
> temp arrays are never deallocated.
>
> How can I solve this problem?
>
> Thanks in advances,
> Pietro Bonfa'
>
>
> P.S: I asked the same question also on stack overflow
> (
> http://stackoverflow.com/questions/17085197/is-this-a-memory-leak-python-numpy
> )
>
> --
> Pietro Bonfa' - PhD student
> Dipartimento di Fisica e Scienze della Terra "Macedonio Melloni"
> Viale delle Scienze 7A
> 43124 Parma - Italy
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130613/0719295f/attachment.html 


More information about the NumPy-Discussion mailing list