Skip to content

Path.exists() - Memory leak#122849

@RegisGraptin

Description

@RegisGraptin

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.

clean_memory_leak

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions