-
-
Notifications
You must be signed in to change notification settings - Fork 164
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 on MacOS #670
Comments
Thanks for reporting. Sounds like a bug to me. I'm also not exactly familiar with the object lifecycle management in CoreFoundation, so I welcome your contrib (or someone else). If someone starts on it, let me know so I can assign the issue to you and avoid duplication of work. |
Hi folks. I've just bumped into this, and I think I've tracked this down. MWE: import gc
import weakref
ref = None
class MyVeryLargeObject:
pass
def f():
global ref
x = MyVeryLargeObject()
ref = weakref.ref(x)
import keyring.backends.Windows
f()
gc.collect()
print(ref()) # <__main__.MyVeryLargeObject object at 0x101611f10> The issue is because this exception trap: keyring/keyring/backends/Windows.py Line 12 in edaa964
is holding on to the exception at the global level forever. This exception keeps a reference to the current traceback, and that tracebacks keeps references to all the local variables up the stack. Replacing I'm not suitably familiar with |
Calling the
keyring.get_password()
function repeatedly on MacOS results in leaked memory. The problem appears to be in find_generic_password(), where the memory allocated bySecItemCopyMatching()
is never released. I spent some time trying to fix the issue, but it was dragging me further into the world of CoreFoundation internals than I had time to go.I don't know how serious the problem is in practice, but using memray I was seeing a non-negligible memory allocation (~30MB) hanging around in my application, attributable to this function.
Thank you so much for your work maintaining this library! If I have more time soon I might return to the issue and attempt a fix.
The text was updated successfully, but these errors were encountered: