Skip to content
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

Circular references when creating Botocore objects #109

Closed
kkopachev opened this issue Mar 7, 2018 · 0 comments · Fixed by #112
Closed

Circular references when creating Botocore objects #109

kkopachev opened this issue Mar 7, 2018 · 0 comments · Fixed by #112

Comments

@kkopachev
Copy link
Collaborator

I discovered recently, that even though thumbor with built-in loaders does not seem to leak (at least heavily), there are still a lot of collectible objects hanging in memory when using tc_aws for storage/loader.

Although, collectible objects does not mean there is a leak, from my understanding there is no guarantee gc will be ever run (or at least run before memkiller chimes in).

Digging dipper, with method described in thumbor/thumbor#753 (comment) I realized that even creating vanilla botocore client and then deleting it would leave some circularly-referenced objects hanging in memory. This behavior also described in boto/botocore#805

botocore team seems to think there is no issue, since all these objects collectible.

Loking at tc_aws package, I realized that code creates new botocore client every time thumbor calls loader. Which then calls Bucket, which calls tornado_botocore

As far as I can see, we could instantiate Bucket objects just once per operation (get/put/delete) and reuse.

My testing shown 1760 objects collected after each creation of Bucket and making request to get a file from S3. However, if we reuse same Bucket object over multiple requests, number of collected objects falls to 34.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant