Skip to content

Weird memory leak #2351

@OmgImAlexis

Description

@OmgImAlexis
  • Node.js Version: v10.16.3
  • OS: Unraid 6.8 (stable)
  • Scope (install, code, runtime, meta, other?): (not sure on what this means?)
  • Module (and version) (if relevant):
  • Extra: I'm using node --optimize_for_size index.js to start my app.

I'm still not sure what's causing this and the issue seems to be buried somewhere within my app. I've tried disabling large sections of the app with some success but the leak just seems to randomly appear again.

I've tried using things such as njstrace to see what's running while the memory is increasing and I never see any functions running. Same goes for using chrome's devtools and debugger statements. Basically comes down to there not being any code run yet memory is increasing. Since I'm not sure what's running I can't find where the leak is. One though I had was it's leaking in a timer somewhere and the tracing methods I've tried aren't catching it?

As you can see the heap seems to recover but RSS continues to grow.

Screen Shot 2019-12-12 at 4 04 19 pm

This is the script I'm using the log the data. It just outputs as | separated and then I put the data into google sheets for the graph. From what I can tell the logMemory function isn't causing any issues.

const fs = require('fs');
const logPath = require('path').resolve(__dirname, 'memory.log');

const logMemory = () => {
    gc();
    const memory = process.memoryUsage();
    fs.appendFile(logPath, `${memory.rss}|${memory.heapTotal}|${memory.heapUsed}|${memory.external}\n`, err => {
        if (err) {
            throw err;
        }
    });
};

setInterval(logMemory, 1000);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions