Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak of sorts #35

Open
abrenneke opened this issue Nov 16, 2017 · 5 comments
Open

Memory leak of sorts #35

abrenneke opened this issue Nov 16, 2017 · 5 comments

Comments

@abrenneke
Copy link

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.

@AndreasMadsen
Copy link
Owner

Unless Error.stackTraceLimit = Infinity it should clean up appropiately.

@abrenneke
Copy link
Author

You can try the above code, it leaks for me. Error.stackTraceLimit = 10, the default

@foray1010
Copy link

foray1010 commented Jan 31, 2018

trace + clarify triggers memory leaks on my application too as following graph shows:

screen shot 2018-01-31 at 2 24 01 pm

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

@jbunton-atlassian
Copy link

jbunton-atlassian commented Mar 5, 2018

@foray1010 I've fixed that memory leak in PR #40

@Somebi
Copy link

Somebi commented Feb 13, 2020

Still leaking, because this PR wasn't merged. This project seems to be dead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants