-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
refleak in C functools.lru_cache #72839
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
Comments
The attached patch fixes a refleak in functools.lru_cache. |
LGTM. |
FWIW, if I comment out this code try: in functools.py to use the pure Python version, then I get much larger numbers: $ ./python -m test -R : test_typing
Run tests sequentially
0:00:00 [1/1] test_typing
beginning 9 repetitions
123456789
.........
test_typing leaked [25003, 25003, 25003, 25003] references, sum=100012
test_typing leaked [9350, 9352, 9352, 9352] memory blocks, sum=37406
test_typing failed |
New changeset ba59f3328032 by Yury Selivanov in branch '3.5': New changeset 5b253d641826 by Yury Selivanov in branch '3.6': New changeset 784fea019cab by Yury Selivanov in branch 'default': |
Oh boy... This is something else. Please re-open bpo-28649 explaining that it now leaks with pure-Python lru_cache. Could you please take a look at it? |
It seems to be unrelated to typing.py def test_lru_type_error(self):
@functools.lru_cache(maxsize=None)
def infinite_cache(o):
pass
with self.assertRaises(TypeError):
infinite_cache([]) I get [2, 2, 2, 2] for unpatched C version (this is now fixed) Should I maybe open a separate issue for this? |
Anyway, this is not urgent, typing.py uses the default version, which is the C version. |
Wow. I can reproduce refleaks in test_typing, but not in test_functools. This is weird. |
Not so sure, a refleak in pure-python version kind of scares me. It can be a bug in the core. |
Indeed, I copied the new test from test_functools to test_typing, but now I see that pure Python version of lru_cache fails even if I remove this test and test that was previously failing with C version (test_extended_generic_rules_eq).
Indeed. Now we need to figure out what it so special about typing that triggers the leak. |
I am not sure what does this mean, but when I remove __slots__ = () from some classes, numbers of leaked references change. |
Ivan, I think I figured it out, I'll close this one and reopen the typing one. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: