
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2016-11-09 23:47 byyselivanov, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| refleak.patch | yselivanov,2016-11-09 23:47 | review | ||
| Messages (12) | |||
|---|---|---|---|
| msg280468 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2016-11-09 23:47 | |
The attached patch fixes a refleak in functools.lru_cache. | |||
| msg280470 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2016-11-09 23:49 | |
LGTM. | |||
| msg280471 -(view) | Author: Ivan Levkivskyi (levkivskyi)*![]() | Date: 2016-11-09 23:51 | |
FWIW, if I comment out this codetry: from _functools import _lru_cache_wrapperexcept ImportError: passin functools.py to use the pure Python version, then I get much larger numbers:$ ./python -m test -R : test_typingRun tests sequentially0:00:00 [1/1] test_typingbeginning 9 repetitions123456789.........test_typing leaked [25003, 25003, 25003, 25003] references, sum=100012test_typing leaked [9350, 9352, 9352, 9352] memory blocks, sum=37406test_typing failed | |||
| msg280472 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2016-11-09 23:57 | |
New changesetba59f3328032 by Yury Selivanov in branch '3.5':Issue#28653: Fix a refleak in functools.lru_cache.https://hg.python.org/cpython/rev/ba59f3328032New changeset5b253d641826 by Yury Selivanov in branch '3.6':Merge 3.6 (issue#28653)https://hg.python.org/cpython/rev/5b253d641826New changeset784fea019cab by Yury Selivanov in branch 'default':Merge 3.6 (issue#28653)https://hg.python.org/cpython/rev/784fea019cab | |||
| msg280473 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2016-11-10 00:03 | |
> FWIW, if I comment out this codeOh boy... This is something else. Please re-open#28649 explaining that it now leaks with pure-Python lru_cache. Could you please take a look at it? | |||
| msg280474 -(view) | Author: Ivan Levkivskyi (levkivskyi)*![]() | Date: 2016-11-10 00:10 | |
It seems to be unrelated to typing.pyWith your test from test_functools: 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)and [24764, 24764, 24764, 24764] for Python version.Should I maybe open a separate issue for this? | |||
| msg280475 -(view) | Author: Ivan Levkivskyi (levkivskyi)*![]() | Date: 2016-11-10 00:13 | |
Anyway, this is not urgent, typing.py uses the default version, which is the C version. | |||
| msg280476 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2016-11-10 00:13 | |
> It seems to be unrelated to typing.pyWow. I can reproduce refleaks in test_typing, but not in test_functools. This is weird. | |||
| msg280477 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2016-11-10 00:17 | |
> Anyway, this is not urgentNot so sure, a refleak in pure-python version kind of scares me. It can be a bug in the core. | |||
| msg280478 -(view) | Author: Ivan Levkivskyi (levkivskyi)*![]() | Date: 2016-11-10 00:26 | |
> Wow. I can reproduce refleaks in test_typing, but not in test_functools. This is weird.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).> Not so sure, a refleak in pure-python version kind of scares me. It can be a bug in the core.Indeed. Now we need to figure out what it so special about typing that triggers the leak. | |||
| msg280479 -(view) | Author: Ivan Levkivskyi (levkivskyi)*![]() | Date: 2016-11-10 00:43 | |
I am not sure what does this mean, but when I remove __slots__ = () from some classes, numbers of leaked references change. | |||
| msg280480 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2016-11-10 01:11 | |
Ivan, I think I figured it out, I'll close this one and reopen the typing one. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:39 | admin | set | github: 72839 |
| 2016-11-10 01:11:57 | yselivanov | set | status: open -> closed title: refleak in functools.lru_cache -> refleak in C functools.lru_cache messages: +msg280480 resolution: fixed stage: needs patch -> resolved |
| 2016-11-10 00:43:18 | levkivskyi | set | messages: +msg280479 |
| 2016-11-10 00:26:52 | levkivskyi | set | messages: +msg280478 |
| 2016-11-10 00:17:26 | yselivanov | set | messages: +msg280477 |
| 2016-11-10 00:14:26 | yselivanov | set | stage: commit review -> needs patch |
| 2016-11-10 00:13:35 | yselivanov | set | messages: +msg280476 |
| 2016-11-10 00:13:16 | levkivskyi | set | messages: +msg280475 |
| 2016-11-10 00:10:29 | levkivskyi | set | messages: +msg280474 |
| 2016-11-10 00:03:00 | yselivanov | set | messages: +msg280473 |
| 2016-11-09 23:57:17 | python-dev | set | nosy: +python-dev messages: +msg280472 |
| 2016-11-09 23:51:37 | levkivskyi | set | nosy: +levkivskyi messages: +msg280471 |
| 2016-11-09 23:49:34 | serhiy.storchaka | set | assignee:yselivanov messages: +msg280470 stage: patch review -> commit review |
| 2016-11-09 23:47:28 | yselivanov | create | |