[Numpy-discussion] python eats memory like the cookie monster eats cookies
Niels Provos
provos@citi.umich....
Sun Feb 4 12:18:00 CST 2007
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.
If anyone could enlighten me about what I am doing wrong, I would very
much appreciate it.
Thank you,
Niels.
More information about the Numpy-discussion
mailing list