FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-151814: Add test for TextIOWrapper.write unbounded memory growth from repeated writes by cmaloney · Pull Request #152244 · python/cpython · GitHub

Repository navigation

gh-151814: Add test for TextIOWrapper.write unbounded memory growth from repeated writes - #152244

Merged
ambv merged 1 commit into
python:mainfrom
cmaloney:gh_151814_test
Oct 23, 2026
Merged

ambv merged 1 commit into
python:mainfrom
cmaloney:gh_151814_test

Conversation

cmaloney commented Jun 26, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Use tracemalloc to measure memory usage.

Fails before GH-151817, passes after. Validated by changing condition between > 0 and >= 0 and rebuilding + running make && ./python -m test test_io.test_textio -m "test_write_empty_no_memory_growth".

if (bytes_len > 0) {

Inspired by the report memory usage helper in GH-152203 (If it gets more use should probably move to test.support).

cc: @StanFromIreland

…owth from repeated writes

Use tracemalloc to measure memory usage.

Copy link
Copy Markdown
Member

Inspired by the report memory usage helper in #152203

You're linking to a PR where they had to fix-up such a test, as such, I'm not convinced this is worth it.

cmaloney commented Jun 26, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

In this case the allocations go on my machine from peak = 3067536 to peak = 0 blocks allocated. I think it's unlikely more allocations will happen in this empty global constant string write case. Even if we do add some new overheads with 200_000 iterations if we allocate 200_000 blocks probably worth making sure the change is intentional. Can up the constant further if worried about other overhead creep as the codebase evolves.

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

github-actions Bot added the stale Stale PR or inactive for long period of time. label Oct 5, 2026
ambv merged commit 2bd9e79 into python:main Oct 23, 2026
54 checks passed
cmaloney deleted the gh_151814_test branch October 23, 2026 18:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news stale Stale PR or inactive for long period of time. tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL