javascript - How to request the Garbage Collector in node.js to run? -


at startup, seems node.js app uses around 200mb of memory. if leave alone while, shrinks around 9mb.

is possible within app to:

  1. check how memory app using ?
  2. request garbage collector run ?

the reason ask is, load number of files disk, processed temporarily. causes memory usage spike. don't want load more files until gc runs, otherwise there risk run out of memory.

any suggestions ?

if launch node process --expose-gc flag, can call global.gc() force node run garbage collection. keep in mind other execution within node app paused until gc completes, don't use or affect performance.

you might want include check when making gc calls within code things don't go bad if node run without flag:

if (global.gc) {     global.gc(); } else {     console.log('garbage collection unavailable.  pass --expose-gc '       + 'when launching node enable forced garbage collection.'); } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -