Title: Path.exists() - Memory leak · Issue #122849 · python/cpython · GitHub
Open Graph Title: Path.exists() - Memory leak · Issue #122849 · python/cpython
X Title: Path.exists() - Memory leak · Issue #122849 · python/cpython
Description: 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 cal...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/python/cpython/issues/122849
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Path.exists() - Memory leak","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nI 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.\r\n\r\nHere is a python script, where I iterate over some items, and when I called the `exists()` function it seems the RAM keeps growing.\r\n\r\n```python\r\nfrom collections.abc import Iterator\r\nfrom pathlib import Path\r\n\r\n\r\ndef check_file(filename: Path) -\u003e None:\r\n if filename.exists():\r\n return\r\n return\r\n\r\n\r\ndef iterate() -\u003e Iterator[int]:\r\n yield from range(10_000_000)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n directory = Path(\"/\")\r\n for item in iterate():\r\n filename = directory / str(item)\r\n check_file(filename)\r\n```\r\n\r\nHere also a screen shot that I have using `memory_profiler` library to illustrate it.\r\n\r\n\r\n\r\nI 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`.\r\n\r\nThanks\r\n\r\n### CPython versions tested on:\r\n\r\n3.12\r\n\r\n### Operating systems tested on:\r\n\r\nLinux","author":{"url":"https://github.com/RegisGraptin","@type":"Person","name":"RegisGraptin"},"datePublished":"2024-08-09T08:30:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/122849/cpython/issues/122849"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9b50bac6-15da-374d-45fd-6303db328750 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A320:28AE23:2203A26:2E65A50:696AC9A0 |
| html-safe-nonce | 6c695fc27b98f7927e47562b91324552b43799fa6a9daa9d7ebfb2c6d0e843cd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzIwOjI4QUUyMzoyMjAzQTI2OjJFNjVBNTA6Njk2QUM5QTAiLCJ2aXNpdG9yX2lkIjoiODU5NzUzMDk2MDY5MTEyMDU0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 09df4fffbfe8a1aa09c789a4be5bdaf5da7dbd9bbd8cb278903f991f058de5bd |
| hovercard-subject-tag | issue:2457402223 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/122849/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2e8b97f8826ceacce660841a213ea8239d803abcf10502fa939fcea5db27b208/python/cpython/issues/122849 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2e8b97f8826ceacce660841a213ea8239d803abcf10502fa939fcea5db27b208/python/cpython/issues/122849 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RegisGraptin |
| hostname | github.com |
| expected-hostname | github.com |
| None | c785f4ce187e9e7331257791b36ddee01625bb8e292a9b4fe2c16d4c006abf5d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c718a376fcf780eb22089171adb84a543f660bf7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width