-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Clients are never GC'd #805
Comments
Taking a look. We have specific tests in place to ensure we don't leak memory when creating clients: https://github.com/boto/botocore/blob/develop/tests/functional/leak/test_resource_leaks.py#L39-L65 One of the things I've noticed from your code is that you're assigning a
However, the real botocore client's don't actually implement a Let me run a few more tests to confirm. |
Here's another test I ran:
Running this I get:
So I'm not able to create a scenario where clients don't get gc'd. If you could share a repro using unmodified clients that leak memory, I can investigate further. |
Hm, I'm sure that
Prints:
|
I will also continue to investigate our code here -- I have a feeling it's related to threading. We do try to use a separate session / client per-thread. |
Interestingly, when I run your original code, I actually see the client being deleted, but not the session:
When I print out the differences in the before and after from your latest code snippet, I don't see any clients: Code:
And those objects above are expected, the session creates them lazily as needed and then reuses those objects across multiple clients which is why they aren't in the "before" list. |
Interesting. I think this might also be related to the fact that we instantiate these clients across different threads. When we inspect the heap, we definitely see lots of things from botocore. I'll see if I can come up with a simple testcase here. |
Closing due to inactivity. If you were able to find any additional info, let us know and I'll reopen and take another look. |
Thanks. We're still having issues, but I haven't gotten around to doing another investigation. It might be due to our use of threads, though. |
I am noticing severe memory leaks in an application that I was porting from using the original boto to boto3. I use a similar pattern for one Session per thread as described here and this started happening as soon as I implemented it. Instead of fire and forget threads that end at some point, this program architecture reuses threads from a pool of 100 threads that start and die with the Main thread. So each of those long living threads will have a boto3 Session attached to it (which I believe has a botocore session object within) and after a few hours, memory usage that is usually below 300MB is now over 3GB and growing. I think this is similar enough to the issue above, but as I'm not using botocore directly, it is hard to say. Can I have some guidance? as I see a pull request for removing circular references and it is not merged |
We hit the very same problem when we call |
hi @nicolefinnie , i am also facing similar issue in my application , can u please suggest the alternatives to boto3 library which u used? |
Prints:
This is causing major memory leaks in our applications that create lots of clients.
The text was updated successfully, but these errors were encountered: