Title: `_remote_debugging`: unbounded memory growth when recording binary and the thread is sleeping · Issue #151378 · python/cpython · GitHub
Open Graph Title: `_remote_debugging`: unbounded memory growth when recording binary and the thread is sleeping · Issue #151378 · python/cpython
X Title: `_remote_debugging`: unbounded memory growth when recording binary and the thread is sleeping · Issue #151378 · python/cpython
Description: Bug report Bug description: When recording binary files, pending RLEs are flushed when the stack is changed: cpython/Modules/_remote_debugging/binary_io_writer.c Lines 1014 to 1018 in 29a920e /* Stack changed - flush any pending RLE firs...
Open Graph Description: Bug report Bug description: When recording binary files, pending RLEs are flushed when the stack is changed: cpython/Modules/_remote_debugging/binary_io_writer.c Lines 1014 to 1018 in 29a920e /* St...
X Description: Bug report Bug description: When recording binary files, pending RLEs are flushed when the stack is changed: cpython/Modules/_remote_debugging/binary_io_writer.c Lines 1014 to 1018 in 29a920e /* St...
Opengraph URL: https://github.com/python/cpython/issues/151378
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`_remote_debugging`: unbounded memory growth when recording binary and the thread is sleeping","articleBody":"# Bug report\n\n### Bug description:\n\nWhen recording binary files, pending RLEs are flushed when the stack is changed:\n\nhttps://github.com/python/cpython/blob/29a920e80e21490b5bdb7178373f80fe606a4403/Modules/_remote_debugging/binary_io_writer.c#L1014-L1018\n\nor on finalize:\n\nhttps://github.com/python/cpython/blob/29a920e80e21490b5bdb7178373f80fe606a4403/Modules/_remote_debugging/binary_io_writer.c#L1077-L1083\n\nSo, a sleeper can cause a memory leak:\n\nhttps://github.com/python/cpython/blob/29a920e80e21490b5bdb7178373f80fe606a4403/Modules/_remote_debugging/binary_io_writer.c#L996-L1012\n\n# Reproduction\n\nAnother one found under \"let's keep recording binary for a while and see what happens\", but the very minimal repro is:\n\n```\n2026-06-11T20:13:39.406750000+0200 maurycy@gimel /Users/maurycy/work/cpython (main d2e27ac?) % ./python.exe -c \"\nimport time\ntime.sleep(3600)\n\" & TARGET=$!\n\nsudo ./python.exe -m profiling.sampling attach --binary -r 1000khz -d 300 -o /tmp/rle.bin $TARGET &\nsleep 2; PROF=$(pgrep -fn \"profiling.sampling attach\")\nfor i in $(seq 5); do printf \"t=%2dmin RSS=%d MB\\n\" $i $(($(ps -o rss= -p $PROF|tr -d ' ')/1024)); sleep 60; done\n[1] 62736\n[2] 62737\nt= 1min RSS=46 MB\nt= 2min RSS=348 MB\nt= 3min RSS=645 MB\nt= 4min RSS=945 MB\nt= 5min RSS=1246 MB\nCaptured 98,200,648 samples in 300.00 seconds\nSample rate: 327,335.49 samples/sec\nError rate: 0.00\n Binary Encoding:\n Records: 1\n RLE repeat: 0 (0.0%) [0 samples]\n Full stack: 1 (100.0%)\n Suffix match: 0 (0.0%)\n Pop-push: 0 (0.0%)\n Frame Efficiency:\n Frames written: 1\n Frames saved: 0 (0.0%)\n Bytes (pre-zstd): 18 B\nWarning: missed 201799353 samples from the expected total of 300000001 (67.27%)\nBinary profile written to /tmp/rle.bin (98200648 samples)\n[2] + done sudo ./python.exe -m profiling.sampling attach --binary -r 1000khz -d 300 -o \n2026-06-11T20:18:42.018130000+0200 maurycy@gimel /Users/maurycy/work/cpython (main d2e27ac?) % \n```\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-152089\n* gh-153047\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/maurycy","@type":"Person","name":"maurycy"},"datePublished":"2026-06-11T18:27:03Z","url":"https://github.com/python/cpython/issues/151378"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:e5d475dd-4717-7c0e-c901-51f3c6a80f14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A506:2E9D3B:A4C8E4:CF45DB:6B022F6D |
| html-safe-nonce | 85e02be9909e40676a03f2f6dd0192ebfface0a513a00eae7ce3db35d1bb3423 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTA2OjJFOUQzQjpBNEM4RTQ6Q0Y0NURCOjZCMDIyRjZEIiwidmlzaXRvcl9pZCI6IjI5NTY2NzIyMzg3MzQxNTk3MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ec22c3590107fdfe576e69127c665e36fc6b4b041e81745c3dbfee4a3b9748cf |
| hovercard-subject-tag | issue:4643153280 |
| 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/151378/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9fc64c165d015b6ab1fa283545147b52166f2c45991899af8eaac0f8aa9a1c96/python/cpython/issues/151378 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9fc64c165d015b6ab1fa283545147b52166f2c45991899af8eaac0f8aa9a1c96/python/cpython/issues/151378 |
| og:image:alt | Bug report Bug description: When recording binary files, pending RLEs are flushed when the stack is changed: cpython/Modules/_remote_debugging/binary_io_writer.c Lines 1014 to 1018 in 29a920e /* St... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maurycy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width