You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Blob allocations cause excessive memory, and GC does not release all memory / Windows 10 / Blob,Uint8Array,ArrayBuffer #20544
functioncreate1GBData(): Blob|(Uint8Array&{size: number}){constsizeInBytes=1024*1024*1024;// 1GBconstbuffer=newArrayBuffer(sizeInBytes);constuint8Array=newUint8Array(buffer);// Fill with patternfor(leti=0;i<sizeInBytes;i++){uint8Array[i]=i%256;}returnnewBlob([uint8Array]);}
Allocate 14 blobs using this function (Array.from({length: 14}, create1GBData)).
Observe memory usage (e.g., via Task Manager).
Force garbage collection (manual GC).
sleep and observe memory utilization.
What is the expected behavior?
Memory usage for Blob allocation should be comparable on Windows and Linux.
Memory should be released after GC, similar to the behavior on Linux and in Node.js.
Returning a Blob should not incur a 5GB+ overhead compared to returning a Uint8Array.
What do you see instead?
On Windows, allocating 14 blobs (~1GB each) results in total memory usage of ~20GB.
After manual GC, around 7GB of memory is not released.
Returning the Uint8Array instead of a Blob allocate less memory but holds on to more memory after GC
On Linux, the same code does not exhibit high memory usage when using Blob, and memory is released after GC.
Node.js does not show this excess memory use on either platform.
Additional information
This issue may indicate a platform-specific memory management bug in Bun's Blob implementation on Windows.
changed the title [-]Blob allocations cause excessive memory, and GC does not release all memory / Windows 10 / `Blob,Uint8Array,ArrayBuffer`[/-][+]Blob allocations cause excessive memory, and GC does not release all memory / Windows 10 / `Blob,Uint8Array,ArrayBuffer`[/+]on Jul 17, 2025
The Blob/ArrayBuffer backing-store allocation code this report exercises has been substantially reworked since the version reported here: the fetch/streams stack now applies real backpressure instead of buffering request and response bodies without bound (#36087, #35843, #36570, and the receive-backpressure work before them), and the GC controller now collects on an idle timer rather than pacing off event-loop activity (#35356). It ships in Bun v1.4.0 and is in the current canary now — bun upgrade --canary.
I couldn't run a self-contained reproduction from this thread, so this is an optimistic close rather than a measured one — if the growth still reproduces on the canary, please post the numbers and we'll reopen and dig in.
(This comment was written by Claude, on behalf of the Bun team.)
Correction to my previous comment: this thread does have a runnable reproduction, and I said it didn't. Reopening — I'm going to run the reproduction here against Bun 1.3.14 and the current canary and post the actual RSS numbers before drawing any conclusion.
(This comment was written by Claude, on behalf of the Bun team.)
Activity
mizulu commentedon Jun 22, 2025
Bun
Node
[-]Blob allocations cause excessive memory, and GC does not release all memory / Windows 10 / `Blob,Uint8Array,ArrayBuffer`[/-][+]Blob allocations cause excessive memory, and GC does not release all memory / Windows 10 / `Blob,Uint8Array,ArrayBuffer`[/+]fitzn commentedon Dec 9, 2025
@mizulu Just curious: does this repro on the latest version of Bun for you?
mizulu commentedon Dec 12, 2025
@fitzn I tried with a simple script (not the full one)
generated 8 blobs of 1GB
actual memory that got allocated was 14gb
still excessive memory usage
as noted by
however it is able to clear the memory after reference removal and GC forced.
fitzn commentedon Dec 12, 2025
@mizulu Roger that. Thanks!
Jarred-Sumner commentedon Aug 1, 2026
The Blob/ArrayBuffer backing-store allocation code this report exercises has been substantially reworked since the version reported here: the fetch/streams stack now applies real backpressure instead of buffering request and response bodies without bound (#36087, #35843, #36570, and the receive-backpressure work before them), and the GC controller now collects on an idle timer rather than pacing off event-loop activity (#35356). It ships in Bun v1.4.0 and is in the current canary now —
bun upgrade --canary.I couldn't run a self-contained reproduction from this thread, so this is an optimistic close rather than a measured one — if the growth still reproduces on the canary, please post the numbers and we'll reopen and dig in.
(This comment was written by Claude, on behalf of the Bun team.)
Jarred-Sumner commentedon Aug 1, 2026
Correction to my previous comment: this thread does have a runnable reproduction, and I said it didn't. Reopening — I'm going to run the reproduction here against Bun 1.3.14 and the current canary and post the actual RSS numbers before drawing any conclusion.
(This comment was written by Claude, on behalf of the Bun team.)