I was running my server with pm2 start ...
and pm2 monit
was showing me 3GB memory
after 2 hours. So I attached memwatch, now I waited for
pm2 start app.js --node-args='--expose-gc'
Above argument --expose-gc will allow us to force call garbage collector from node js, now use following code for force garage collection.
if (global.gc) {
global.gc();
} else {
console.log('Garbage collection unavailable. use --expose-gc '
+ 'when launching node to enable forced garbage collection.');
}
This will solve PM2 meomry leak problem.