TEST STEPS:
- Create a new folder
- Run
npm init
- Run
npm install mustache@4.2.0
- 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();
- Run code with inspector
node --inspect index.js.
- Open Chrome Inspector
chrome://inspect/
- Click on
inspect link
- Select
Memory tab
- Click on
Take heap snapshot icon once a minute.
ACTUAL RESULT:
The memory heap linearly grows.
EXPECTED RESULT:
The memory heap should not grow.

TEST STEPS:
npm initnpm install mustache@4.2.0index.jsnode --inspect index.js.chrome://inspect/inspectlinkMemorytabTake heap snapshoticon once a minute.ACTUAL RESULT:
The memory heap linearly grows.
EXPECTED RESULT:
The memory heap should not grow.