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
There are a lot of really bad answers on this thread. Really, really bad.
The answer is simple: your code has a memory leak that you need to find and remove, and it's VERY UNLIKELY that the GC is wrong, it's far more likely your code is the culprit.
So first off:
Secondly, the actual solution should be:
Profile your code's memory and CPU usage using the tool of your choice. For most people, that is going to be Chrome's debugging tools connected to the running node instance, and look at which functions are causing memory usage to spike. Simply calling the GC manually is lazy because your code still has a leak but you're just telling V8 to constantly hoover up memory after your app leaks it, which is very lazy practice.