Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite the internal Web Stream native bindings to use less memory #16349

Merged
merged 5 commits into from
Jan 26, 2025

Conversation

Jarred-Sumner
Copy link
Collaborator

What does this PR do?

Fixes #12198
Closes #16075

The usage of type: "bytes" in our lazy internal ReadableStream sources led to a memory leak because each read from the stream sometimes returns a larger & different buffer than the one the user provides.

How did you verify your code works?

The version using Node APIs uses the same amount of memory as the version using Bun/Web APIs.

Will follow up with a memory leak test once a release build is generated in CI.

@robobun
Copy link

robobun commented Jan 12, 2025

@leeoniya
Copy link

totally drive-by comment, but a PR title like "Streams: Fix memory leak with type: "bytes"" would be much nicer than "Fixes #12198". does the tl;dr without clicking around for context :)

@DonIsaac
Copy link
Contributor

Additionally, JSC's GC was not being informed of allocations in BufferedReader. Since the GC didn't know memory pressure was increasing, it never knew it needed to sweep old objects out of the heap. This is now fixed.

@Jarred-Sumner Jarred-Sumner changed the title Fixes #12198 Rewrite the internal Web Stream native bindings to use less memory Jan 26, 2025
@Jarred-Sumner Jarred-Sumner merged commit 75a95aa into main Jan 26, 2025
7 of 30 checks passed
@Jarred-Sumner Jarred-Sumner deleted the jarred/fix-leak branch January 26, 2025 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Streams memory leak
4 participants