Sunday, May 22, 2022

node.js trigger gc

 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();
}



No comments: