trace
trace copied to clipboard
Memory leak of sorts
Hello, infinitely recursing setTimeout
calls will increase the memory usage forever.
Reproduction code: (node 8.9.1)
require('trace');
const memwatch = require('memwatch-ng');
memwatch.on('leak', info => {
console.log('Memory leak detected.');
console.log(info);
});
function loop (func) {
const execute = () => {
func().then(() => {
setTimeout(execute, 0);
});
};
execute();
}
console.log(`Stack trace limit is: ${Error.stackTraceLimit}`);
loop(async () => {
await new Promise(resolve => setTimeout(resolve, 0));
});
I don't suppose there's a way for trace
to limit its memory usage? I understand that I'm essentially creating an infinitely long stack trace, but this code does work without trace enabled.
Unless Error.stackTraceLimit = Infinity
it should clean up appropiately.
You can try the above code, it leaks for me. Error.stackTraceLimit = 10, the default
trace + clarify triggers memory leaks on my application too as following graph shows:

23 Jan is the day I apply trace with clarify --stack_trace_limit=100 -r trace -r clarify
, the app keeps using too much memory and kill itself
@foray1010 I've fixed that memory leak in PR #40
Still leaking, because this PR wasn't merged. This project seems to be dead.