Large Numeric arrays

Alex alex at somewhere.round.here
Thu Sep 30 19:07:12 EDT 1999


> I'm passing fairly large arrays around (using Numeric Py)
> and I'm getting the error:
> 
> 	  MemoryError: can't allocate memory for array

I have run into this problem before when writing C.  I would have
something like 

unsigned long int big_array[20][20][20][20][20];

and my program would segfault before it even started executing the
main() function, even though I had plenty of memory.  The problem went
away when I made big_array an

(unsigned long int)*****

and assigned the array elements in slices at execution time.  My theory
was that the program wanted to lay the whole array down contiguously,
and there was no contiguous chunk of memory available for that, even
though the total memory available was more than enough.  

I know very little of the Numeric internals, but the manual says "Arrays
created from scratch are always contiguous; non-contiguous arrays are
the result of indexing and other structural operations."  Perhaps you
could make your arrays in slices, and then glom the slices together?

Alex.





More information about the Python-list mailing list