New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak #37
Comments
Not sure why code got broken down into sections but it is all one piece of code added as zip |
I moved the helper class in the module namespace which seems to fix the garbage collection, but the memory usage is still quite high. Any suggestions? |
Thanks! I'll use your version. As a separate observation. Given that I had to review the entire code while tracking down the memory leak I noticed that you have a few calls like this, About "high memory" comment, not sure what you mean. If you are referring to the section,
then that part was just an isolated test to prove a point without using filelock.py at all. To fix this one you'd have to do the same fix you did and move I hope this is what you meant. btw thanks for your effort on this module. It is extremely handy!! |
I don't like the log thing either, but a user had an issue with the configuration (issue #24) and it was a small change. I used this code to run some tests and forgot that range is not an iterator in Python 2... So nvm. lockPath = "./my_lock"
lock = FileLock(lockPath)
lock.acquire()
for i in range(10**7):
lock.acquire()
lock.release()
lock.release() |
The acquire function defines
class ReturnProxy(object):
inside its function.
This results in an obscure circular reference on the class (at least in Python 2) and memory is leaked. What leaks is the class (not the instance of the class) .
I noticed because when we run our test suite we enable gc debug . To reproduce you can do the code below. It will render the object being leaked. If you want to prove memory is indeed being leaked, just change the if 0 for if 1 and see your RAM shoot up.
For now I worked around it myself by taking the class out of the function.
The text was updated successfully, but these errors were encountered: