[Tutor] numpy memory muncher

Python python at venix.com
Mon Nov 13 21:05:03 CET 2006

On Sat, 2006-11-11 at 15:40 -0500, Joel Levine wrote:
> I'm using, perhaps misusing numpy which is eating up the memory and,
> eventually crashing my program.

I can reproduce the problem on my Linux system, so it is not Mac
specific.  Using xrange makes no difference.

Oddly enough,
	print a[row,col]
does not cause the memory usage to grow.  

I guess numpy needs to allocate some memory when binding a python
variable to an array element.  This memory does not appear to get
released when the python variable is deleted or passes out of scope.

The gc (garbage collector) module did not shed any light for me.

> Isolating it, the following piece of code continually eats memory.  Is it my program or what ...? 
> Thanks
> Joel Levine
> Using Mac OSX 10.4.7
> Not clear on versions:  Appears to be 0.9.8 with py2.4
> -----------------
> from numpy import *
> a=zeros((2000,100),float)
> while True:
>     for row in range(2000):
>         for col in range(100):
>             x=a[row,col]
>             #if x!=0: print "?"
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
Lloyd Kvam
Venix Corp

More information about the Tutor mailing list