I don\'t know if this is a bug with Node or V8, but if I run the following code the node process leaks memory. The GC never seems to kick in and in a few seconds it\'s consuming
As Node.js v0.10 has been released, setImmediate should be used as the first choice instead of process.nextTick
when calling the recursive callback.
function loginf() {
console.log(1+1);
setImmediate(loginf);
}
loginf();
The memory consumption of this chunk of code kept low ( <10MB ) after running for about 15 mins on my computer.
On the contrary, Running the infinite for loop
caused memory leek and the process.nextTick
throwed an Maximum call stack size exceeded
error.
Check this Q&A also: setImmediate vs. nextTick