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
Reference cycles (zombis objects) in SortedDict #147
Comments
It’s possible to create reference cycles with any container object. I can’t think of anything specific about the design of sortedcontainers that would create reference cycles. Please include code to demonstrate. |
I think that a reference cycle appears somewhere inside a SortedDict object.
Output
As you can see a regular dict is deallocated right after |
Thank you for the code sample. I did a bit of debugging and traced the issue to this code in
SortedDict references dict through its base class reference and here the super call forces the dict methods to reference One fix would be to stop using super() and access the dictionary methods as I'm not sure if this is worth fixing. Typically I only use a few SortedDict objects in a program. What's your use case like? |
Caching dict methods using super creates a reference cycle which increases memory pressure. User reported increased latencies due to GC pauses.
Fix pushed at 2b03703. Will deploy new version once Travis/AppVeyor are green. @pivosan97 Would you please test on master? Also, I would appreciate if you did not leave comments like this https://pythontips.com/2016/04/24/python-sorted-collections/comment-page-1/#comment-75266 for an open and on-going issue. My last comment (above) ended with "What's your use case like?" for which I didn't hear back. |
Hi,
Thank you for fixing it.
I think the comment is valid as it reflects my experience with the lib.
I do not know how to delete it, so I’ll replay to it saying that the issue is resolved.
Best regards,
Aliaksandr Pivavarchyk
… On Jun 4, 2020, at 06:42, Grant Jenks ***@***.***> wrote:
Fix pushed at 2b03703 <2b03703>. Will deploy new version once Travis/AppVeyor are green.
@pivosan97 <https://github.com/pivosan97> Would you please test on master?
Also, I would appreciate if you did not leave comments like this https://pythontips.com/2016/04/24/python-sorted-collections/comment-page-1/#comment-75266 <https://pythontips.com/2016/04/24/python-sorted-collections/comment-page-1/#comment-75266> for an open and on-going issue. My last comment (above) ended with "What's your use case like?" for which I didn't hear back.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#147 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACXX2EH4KLE3FQMNT5ECTELRU4X4FANCNFSM4M6VPVRQ>.
|
Fix deployed in version 2.2.0 on PyPI: https://pypi.org/project/sortedcontainers/2.2.0/ |
SortedDict
creates reference cycles (zombie objects) which are not destroyed by reference counting algorithm but only by garbage collector iteration, what can cause performance and latency issues. It can be tracked usinggc
module.The text was updated successfully, but these errors were encountered: