-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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 count variations after getting __dict__
, getattr
, and gc.collect
#115822
Comments
I'll bisect this. |
Could look at a8b9350 |
Bisected to #106539 -- “Dematerialize instance dictionaries when possible”. That makes sense :) Don't know if we can meaningfully control dict (de)materialization. |
I'll prepare a PR. |
Ah, not that easy: getattr searches more than just the dict. @brandtbucher, any ideas would be welcome :) |
I've spent some time reading up on the dict dematerialization implementation, and the public discussion. Now, it seems there's not much to be done about the refcount oscillation. The original proposal about avoiding Perhaps it'll be better to teach the tests about what kind of “leaks” are expected. |
There's a chance we may ditch dict dematerialization for a simpler scheme in the future. So this problem may resolve itself for 3.13 or 3.14. |
__dict__
, getattr
, and gc.collect
The following program accesses
__dict__
(!) and some attributes of two different classes, in a loop.After some of the loops, the total reference count is exactly 2 less than usual. In this case, it's every 5th run of the outer loop:
The code is a highly simplified version running
test_typing
in refleak mode (-R:
), wherea
andb
correspond totyping.Tuple
andtyping.List
. In the actual test, this happens with more classes, and more overlapping “periods”. Sometimes, the test doesn't meet our (currently rather generous) heuristic, and fails.The behaviour is ultimately benign, but it interferes with reference leak testing. We should find out what's happening and make regrtest clear any caches and revert to a known state.
The text was updated successfully, but these errors were encountered: