gpu.js icon indicating copy to clipboard operation
gpu.js copied to clipboard

Dynamic output memory leak

Open Chornomor78 opened this issue 7 months ago • 1 comments

On Windows 11, node.js v20.14.0 I have a memory leak in the case of dynamic output:

const {GPU} = require('gpu.js');
const gpu = new GPU();

const test = gpu.createKernel(function() {
	return 1;
}).setDynamicOutput(true);

for (let i=0; i<1e6; i++) {
	const size = 100; // we can generate a random output size

	test.setOutput([size]); // without this line memory doesn't leak

	const sum = test().reduce((a,e)=>a+e); // use the result

	if (i % 1000 == 0)
		console.log(i + ": " + sum); // debug logging
}

Memory leak can be seen in Task Manager.

Chornomor78 avatar Apr 24 '25 08:04 Chornomor78