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
{{ message }}
Repository navigation
Unique pathlib.Path instances cause memory usage to increase indefinitely in 3.12 only #121780
Hi! The above code cause constant memory usage increase on Linux. I left print of current memory usage, but it's not needed. Tools like memray and my investigation shows it can be related to sys.intern use in pathlib _parse_path func. From my understanding memory is not cleared after references are gone (or looking at what this function does new memory should not be allocated in interned table at some point like seems to be a case in other cpython versions, just a guess tho, i didn't dive that deep). Even if this is completely different issue or expected behaviour, I would expect memory to not increase forever and the code works as I would expect in 3.11.
I've been only able to reproduce it on Debian and Ubuntu (amd64) for python 3.12, not for 3.11,10,9,8 and not 3.13.0b3.
Initially I was debugging memory problems in a code that creates quite many unique paths and it was weird that memory usage was very high after program was running for weeks in kubernetes (plus then some spare hours to eventually find the culprit), so definitely it can have an impact. In a code that doesn't create a lot of stuff, difference can be subtle and negligible.
Activity
TeamSpen210 commentedon Jul 15, 2024
See #113993 and #119518, the fix needs to be backported to 3.12 still.