[Numpy-discussion] python eats memory like the cookie monster eats cookies
Niels Provos
provos@citi.umich....
Sun Feb 4 15:33:05 CST 2007
The missing imports are
import Numeric # for zeros and ones
from scipy.fftpack import fft2,ifft2
Curiously, replacing Numeric.zeros with scipy.zeros makes the problem
go away. Why?
Thank you,
Niels.
On 2/4/07, Robert Kern <robert.kern@gmail.com> wrote:
> 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.
> >
> > def ZeroPadData(A, shape):
> > a = Numeric.zeros(shape, 'w')
> > a.savespace()
> >
> > for y in xrange(A.shape[0]):
> > for x in xrange(A.shape[1]):
> > a[y, x] = A[y, x]
> >
> > return a
> >
> > def EatMemoryLikeTheCookieMonster(limit=10):
> > A = Numeric.ones([1998, 3022])
> >
> > count = 0
> > a = A
> > while count < limit:
> > print count
> > count += 1
> >
> > a = ZeroPadData(a, [2048, 4096])
> >
> > b = fft2(a)
> > b = ifft2(b)
> >
> > a = b[:1998,:3022].real
> >
> > EatMemoryLikeTheCookieMonster()
> >
> > This is for Python 2.4.3 on Mac OS X 10.4.8 (intel) using SciPy 0.5.2.
>
> Could you also post a complete example? Why are you using Numeric? scipy 0.5.2
> requires numpy, not Numeric. Where are the fft2() and ifft2() functions coming
> from, scipy.fftpack or numpy?
>
> --
> 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
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
More information about the Numpy-discussion
mailing list