This sounds odd. My PyPy does not leak memory in this example. Can you
please double check?

On Tue, Jul 30, 2013 at 2:43 AM, Nathan Hurst <[email protected]> wrote:
> 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
> _______________________________________________
> pypy-dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/pypy-dev
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to