question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak of sorts

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
jbunton-atlassiancommented, Mar 5, 2018

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

1reaction
Somebicommented, Feb 13, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak - Wikipedia
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in...
Read more >
Three kinds of memory leaks - Made of Bugs - Nelson Elhage
Made of Bugs · Three kinds of memory leaks · Type (1): Unreachable allocations ︎ · Type (2): Unexpectedly long-lived allocations ︎ ·...
Read more >
4 Types of Memory Leaks in JavaScript and How to Get Rid Of ...
4 Types of Memory Leaks in JavaScript and How to Get Rid Of Them · 1. Accidental global variables · 2. Forgotten timers...
Read more >
How to Detect Memory Leaks in Java: Causes, Types, & Tools
Common causes for these memory leaks are: Excessive session objects. Insertion without deletion into Collection objects.
Read more >
The seventeen types of memory leak | Software Verify
Memory leaks fall into one of several categories. · #1 Leaked temporary workspace. · #2 Leaked data member · #3 Leaked class static...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found