Title: concurrent.futures.ThreadPoolExecutor does not free memory when shutdown · Issue #98467 · python/cpython · GitHub
Open Graph Title: concurrent.futures.ThreadPoolExecutor does not free memory when shutdown · Issue #98467 · python/cpython
X Title: concurrent.futures.ThreadPoolExecutor does not free memory when shutdown · Issue #98467 · python/cpython
Description: Bug report Memory allocated in threads is never freed when using a ThreadPoolExecutor. The expected behavior is that when the executor is shut down, all memory allocated in its threads should be freed. The below code demonstrates this le...
Open Graph Description: Bug report Memory allocated in threads is never freed when using a ThreadPoolExecutor. The expected behavior is that when the executor is shut down, all memory allocated in its threads should be fr...
X Description: Bug report Memory allocated in threads is never freed when using a ThreadPoolExecutor. The expected behavior is that when the executor is shut down, all memory allocated in its threads should be fr...
Opengraph URL: https://github.com/python/cpython/issues/98467
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"concurrent.futures.ThreadPoolExecutor does not free memory when shutdown ","articleBody":"# Bug report\r\n\r\nMemory allocated in threads is never freed when using a ThreadPoolExecutor. The expected behavior is that when the executor is shut down, all memory allocated in its threads should be freed. The below code demonstrates this leak in that the the memory usage before allocating memory in threads is significantly less than after. \r\n\r\n```python\r\nfrom concurrent.futures import ThreadPoolExecutor, as_completed\r\nimport resource\r\n\r\ndef process_user(x):\r\n return bytearray(10000000) \r\n\r\nprint('Before', resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024, 'MB')\r\n\r\ndef leak_memory():\r\n with ThreadPoolExecutor(max_workers=20) as executor:\r\n futures = [executor.submit(process_user, i) for i in range(100)]\r\n for future in as_completed(futures):\r\n cur = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024\r\n print('Step', cur)\r\n\r\nleak_memory()\r\n\r\nprint('After', resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024, 'MB')\r\n```\r\n\r\n# Your environment\r\n\r\nPython 3.9.x/3.10.x. Mac os and debian.\r\n\r\n","author":{"url":"https://github.com/eMeena","@type":"Person","name":"eMeena"},"datePublished":"2022-10-19T21:30:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/98467/cpython/issues/98467"}
| 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:5cea719f-8428-0fd9-27f5-be5bea84fb7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C08:1219C5:82695D:B6932D:696A20EB |
| html-safe-nonce | 3ea3fe412505e2f7550d24a65fc37357704c541e198228c6c38de42122a6d60a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzA4OjEyMTlDNTo4MjY5NUQ6QjY5MzJEOjY5NkEyMEVCIiwidmlzaXRvcl9pZCI6IjI4NzU5MDUwODIzNTMzOTM4OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 86428378a5ef69e9b12a0be04da5f143f6a0363c74105cf600a9385b53a5984f |
| hovercard-subject-tag | issue:1415607834 |
| 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/98467/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1e7d6f9409c3ac4b8756212afe6afc2baaf7eb12a1024ec121f664aa62ba54d2/python/cpython/issues/98467 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1e7d6f9409c3ac4b8756212afe6afc2baaf7eb12a1024ec121f664aa62ba54d2/python/cpython/issues/98467 |
| og:image:alt | Bug report Memory allocated in threads is never freed when using a ThreadPoolExecutor. The expected behavior is that when the executor is shut down, all memory allocated in its threads should be fr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eMeena |
| hostname | github.com |
| expected-hostname | github.com |
| None | 014f3d193f36b7d393f88ca22d06fbacd370800b40a547c1ea67291e02dc8ea3 |
| 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 | d515f6f09fa57a93bf90355cb894eb84ca4f458f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width