Suppose you have a function like f that calls a function m.g:
def f(x):
return m.g(x, 2*x, x+1)
and f gets called a lot, so PyPy JITs it and inlines m.g into it. What if later, due to the "dynamic" nature of Python, m.g gets replaced by something else: Will the old JITed version of f be discarded right away, or could it still be called accidentally?
Also, what if your program does these redefinitions a lot, can the discarded JITed versions cause a memory leak?
To answer your last question: "if your program does these redefinitions a lot, can the discarded JITed versions cause a memory leak?" This is a good question, and the answer might be yes in some cases. The bad case might be if g is a function you just created with exec or eval, so that there is an unbounded number of function objects that end up being called here. This is a problem that we thought about fixing in the past, but never got around to do it. If you are experiencing what looks like a leak and have isolated this part of the code, then I'd say chances are that it is exactly what you are fearing. In that case, I'd recommend to write a mail to [email protected] or come to #pypy on irc.freenode.net to describe your case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With