Title: Runaway memory use when repeatedly printing empty string · Issue #151814 · python/cpython · GitHub
Open Graph Title: Runaway memory use when repeatedly printing empty string · Issue #151814 · python/cpython
X Title: Runaway memory use when repeatedly printing empty string · Issue #151814 · python/cpython
Description: Bug report Bug description: Printing the empty string in a loop seems to cause memory use of Python to grow without bound. while True: print('', end='') or import sys while True: sys.stdout.write('') The latter apparently does not work i...
Open Graph Description: Bug report Bug description: Printing the empty string in a loop seems to cause memory use of Python to grow without bound. while True: print('', end='') or import sys while True: sys.stdout.write('...
X Description: Bug report Bug description: Printing the empty string in a loop seems to cause memory use of Python to grow without bound. while True: print('', end='') or import sys while True: sy...
Opengraph URL: https://github.com/python/cpython/issues/151814
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Runaway memory use when repeatedly printing empty string","articleBody":"# Bug report\n\n### Bug description:\n\nPrinting the empty string in a loop seems to cause memory use of Python to grow without bound.\n\n```python\nwhile True:\n print('', end='')\n```\nor\n```python\nimport sys\n\nwhile True:\n sys.stdout.write('')\n```\nThe latter apparently does not work in interactive mode.\n\nRelatedly,\n```python\nwhile True:\n for _ in range(10**8):\n print('', end='')\n print()\n```\ncauses memory use to grow to about 1.5GB and then reset when the newline is printed.\n\n### CPython versions tested on:\n\n3.14, 3.11, 3.13\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-151817\n* gh-152071\n* gh-152072\n* gh-152073\n* gh-152244\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/pastries-yay","@type":"Person","name":"pastries-yay"},"datePublished":"2026-06-20T18:29:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/151814/cpython/issues/151814"}
| 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:15f6d81d-2404-9ca2-a5c8-b995352648fa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B8B8:223B79:2CF461:3D52F4:6A52598F |
| html-safe-nonce | 52ef5c9c7e01d3c251fde7ef811cb69c97bdb66cb2bbf69afd5e63b38160298c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEI4OjIyM0I3OToyQ0Y0NjE6M0Q1MkY0OjZBNTI1OThGIiwidmlzaXRvcl9pZCI6IjkwMTIyMTUyMDcwOTU4NTE0MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9c7293b9c1856488c1ce2cf6b557808318bb1ed47a05f0a4a72cf57740cd65c6 |
| hovercard-subject-tag | issue:4707929823 |
| 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/151814/issue_layout |
| twitter:image | https://opengraph.githubassets.com/727e7e5a80d285cf77c2ef39787d812887d2707a95fb037b824954ab5f1555d2/python/cpython/issues/151814 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/727e7e5a80d285cf77c2ef39787d812887d2707a95fb037b824954ab5f1555d2/python/cpython/issues/151814 |
| og:image:alt | Bug report Bug description: Printing the empty string in a loop seems to cause memory use of Python to grow without bound. while True: print('', end='') or import sys while True: sys.stdout.write('... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pastries-yay |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width