-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
fix: memory leak when reading chunks from a stream #16075
base: main
Are you sure you want to change the base?
Conversation
.temporary => |*temporary| temporary.deinitWithAllocator(bun.default_allocator), | ||
.temporary_and_done => |*temporary_and_done| temporary_and_done.deinitWithAllocator(bun.default_allocator), | ||
else => {}, | ||
} | ||
result.* = .{ .temporary = .{} }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this cause JSValues for .owned
, etc. variants to point to leaked/undefined memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does line 1046 move or borrow?
Man I miss Rust's borrow checker...
@@ -1021,6 +1023,11 @@ pub const StreamResult = union(Tag) { | |||
const value = result.toJS(globalThis); | |||
value.ensureStillAlive(); | |||
|
|||
switch (result.*) { | |||
.temporary => |*temporary| temporary.deinitWithAllocator(bun.default_allocator), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temporary should mean that the StreamResult don't own the data and should be cloned, the owner (how created the StreamResult) should free it.
I'm skeptical this is either the cause or the fix. More likely, we're not reporting the memory allocated in ArrayBufferSink to the GC, so it has no idea we allocated a bunch of memory. |
What does this PR do?
Fixes #12198