[Numpy-discussion] python eats memory like the cookie monster eats cookies

Robert Kern robert.kern@gmail....
Mon Feb 5 00:48:19 CST 2007

Niels Provos wrote:
> Good morning,
> not sure if I got the right list, but I hope that somebody here will
> be able to shed some light on a Python-related memory problem.  The
> following code eats over >2GB of memory and fails with MemoyError
> after just a few iterations.

Here is a minimal example that demonstrates the problem. It appears that
assigning a numpy scalar to an element in an n-D Numeric array (where n is
strictly > 1) leaks memory. Neither the data-types of the Numeric array nor the
numpy scalar type seem to matter.

import Numeric
import numpy
a = Numeric.zeros([1, 1])
while True:
    a[0, 0] = numpy.int32(0)

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

More information about the Numpy-discussion mailing list