[pypy-dev] memory leak in pypy
Nathan Hurst
njh at njhurst.com
Tue Jul 30 02:43:23 CEST 2013
I was playing with this simple function to compute uint/3. It does
not (afaict) directly allocate any memory, but when run it rapidly
consumes all memory (32GB):
def divu3(n):
q = (n >> 2) + (n >> 4) # q = n*0.0101 (approx).
q = q + (q >> 4) # q = n*0.01010101.
q = q + (q >> 8) # q = n*0.01010101.
q = q + (q >> 16) # q = n*0.01010101.
r = n - q*3 # 0 <= r <= 15.
return q + (11*r >> 5) # Returning q + r/3.
for i in range(2**31):
assert(divu3(i) == i/3)
Python 2.7.3 (daf1b0412bfbd0666c19d567e37b29e4a3be5734, Jul 12 2013, 19:10:57)
[PyPy 2.1.0-beta1 with GCC 4.7.2] on linux2
is it being over eager to specialise?
njh
More information about the pypy-dev
mailing list