javascript - How to request the Garbage Collector in node.js to run? - Stack Overflow
If you launch the node process with the --expose-gc flag, you can then call global.gc() to force node to run garbage collection.
try {
if (global.gc) {global.gc();}
} catch (e) {
console.log("`node --expose-gc index.js`");
process.exit();
}