You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
assignee=Noneclosed_at=<Date2017-08-31.22:23:00.056>created_at=<Date2017-08-31.20:18:11.860>labels= ['3.7', 'performance']
title='Memory leak in dict with shared keys'updated_at=<Date2017-08-31.22:23:00.054>user='https://github.com/vstinner'
It seems like Thread2 constructor creates a dictionary on "self.hashvalue = (...)". It's a dictionary sharing keys, but it seems like the dict table memory is not released whne the bug occurs.
Sadly, I'm only able to reproduce the bug on a 32-bit build. Since the bug depends on exact hash values, maybe the bug exists in 64-bit builds, but is less likely?
I'm not 100% sure if the bug is related to dict or set.
If you cannot reproduce the bug on 32-bit build, try to set "FIXED_HASH = 0" in test_leak.py, run "./python -m test -R 3:10 test_leak" multiple times until it fails, then copy the last value of the printed list into hash_values in test_leak.py.
Activity
vstinner commentedon Aug 31, 2017
Copy attached test_leak.py to Lib/test/ and run:
haypo@selma$ ./python -m test -R 3:30 test_leak
Run tests in parallel using 1 child processes
0:00:00 load avg: 0.67 [1/1/1] test_leak failed
beginning 33 repetitions
123456789012345678901234567890123
.................................
test_leak leaked [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] memory blocks, sum=30
1 test failed:
test_leak
Total duration: 682 ms
Tests result: FAILURE
It seems like Thread2 constructor creates a dictionary on "self.hashvalue = (...)". It's a dictionary sharing keys, but it seems like the dict table memory is not released whne the bug occurs.
Sadly, I'm only able to reproduce the bug on a 32-bit build. Since the bug depends on exact hash values, maybe the bug exists in 64-bit builds, but is less likely?
I'm not 100% sure if the bug is related to dict or set.
The bug comes from bpo-31217.
vstinner commentedon Aug 31, 2017
If you cannot reproduce the bug on 32-bit build, try to set "FIXED_HASH = 0" in test_leak.py, run "./python -m test -R 3:10 test_leak" multiple times until it fails, then copy the last value of the printed list into hash_values in test_leak.py.
vstinner commentedon Aug 31, 2017
I spent a lot of time in gdb, but I'm not sure anymore that the issue is related to dict shared keys.
pitrou commentedon Aug 31, 2017
It's a really weird bug you found. It depends on the exact values passed to -R:
pitrou commentedon Aug 31, 2017
Actually, it's not the bug that is weird, but the heuristics in -R seem completely weird now. If I print the alloc and rc deltas:
pitrou commentedon Aug 31, 2017
s/completely weird/broken/
pitrou commentedon Aug 31, 2017
To come back to this bug, it still fails if add a __slots__, so I don't think it's related to shared key dictionaries.
vstinner commentedon Aug 31, 2017
Antoine: "Actually, it's not the bug that is weird, but the heuristics in -R seem completely weird now. If I print the alloc and rc deltas:"
I changed it recently to reduce false alarms: see bpo-30776.
Antoine: "To come back to this bug, it still fails if add a __slots__, so I don't think it's related to shared key dictionaries."
Oh ok, in that case, I will move back to bpo-31217. I close this issue as a duplicate.