Bug report
Bug description:
I am currently having an issue when using Path.exists() function. It seems that if you use it for intensive usage, I have a memory leak.
Here is a python script, where I iterate over some items, and when I called the exists() function it seems the RAM keeps growing.
fromcollections.abcimportIteratorfrompathlibimportPathdefcheck_file(filename: Path) ->None:
iffilename.exists():
returnreturndefiterate() ->Iterator[int]:
yieldfromrange(10_000_000)
if__name__=="__main__":
directory=Path("/")
foriteminiterate():
filename=directory/str(item)
check_file(filename)Here also a screen shot that I have using memory_profiler library to illustrate it.

I do not know if I am missing something here... Let me know if you need more info to reproduce it. I am using Python 3.12.3 on Ubuntu 22.04.4 LTS.
Thanks
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Bug report
Bug description:
I am currently having an issue when using
Path.exists()function. It seems that if you use it for intensive usage, I have a memory leak.Here is a python script, where I iterate over some items, and when I called the
exists()function it seems the RAM keeps growing.Here also a screen shot that I have using
memory_profilerlibrary to illustrate it.I do not know if I am missing something here... Let me know if you need more info to reproduce it. I am using
Python 3.12.3onUbuntu 22.04.4 LTS.Thanks
CPython versions tested on:
3.12
Operating systems tested on:
Linux