MemoryError Numarray

Robert Kern rkern at ucsd.edu
Mon Sep 26 03:26:08 EDT 2005


Bernhard Reimar Hoefle wrote:
> I have the following python script:
> #######################################
> from numarray import *
> 
> while 1:
> 	a=arange(1,300000000)
> 	b=a*100/100
> 	del a
> 	del b
> #######################################
> 
> This script crashes after a few minutes with an error:
> 
> MemoryError: Couldn't allocate requested memory
> 
> How can I avoid python to use new memory space for each loop?

It's entirely possible that you're running out of memory *during* the
first loop. The a array takes up over 1Gb by itself. a*100 is a
temporary array that takes another 1Gb, and finally b takes up another
1Gb. So you have over 3Gb that's trying to exist at the same time.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list