Description
I am seeing memory leaks when using the mpfr
type as provided by gmpy2
, both under MacOS X and Ubuntu. This issue currently prevents me from using gmpy2
in practice for some use cases in my research.
For example, the below snippet causes memory leaks (at a fairly alarming rate):
from gmpy2 import mpfr
while True:
x = mpfr("84893483948848934839488489348394884893483948848934839488489348394884893483")
The memory leak issue is not restricted to the initialization routine, however. I also experience it in, for instance, an implementation of LLL that I recently wrote. Meanwhile, the following snippet does not leak memory:
from gmpy2 import mpz
while True:
x = mpz("84893483948848934839488489348394884893483948848934839488489348394884893483")
It seems the issue is related to arithmetic involving the mpfr
type.
Can someone else please confirm this? Is this already a known issue? Am I doing something wrong when I expect the garbage collector to handle freeing memory for the mpfr
type?