Skip to content

Memory leak when passed any object to render #818

@koshkarov

Description

@koshkarov

TEST STEPS:

  1. Create a new folder
  2. Run npm init
  3. Run npm install mustache@4.2.0
  4. Create file index.js
const mustache = require("mustache");

function sleep(ms) {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
}

async function run() {
  await sleep(15000);
  for (let i = 0; i < 20; i++) {
    for (let j = 0; j < 15000; j++) {
      // test line
      mustache.render(`MemoryLeakMessage: ${i}:${j}`, null);

      // this allows to interrupt the process and collect garbage
      await sleep(0);
    }
    await sleep(5000);
  }
}

void run();
  1. Run code with inspector node --inspect index.js.
  2. Open Chrome Inspector chrome://inspect/
  3. Click on inspect link
  4. Select Memory tab
  5. Click on Take heap snapshot icon once a minute.

ACTUAL RESULT:
The memory heap linearly grows.

EXPECTED RESULT:
The memory heap should not grow.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions