NodeJS: does calling global.gc () reduce memory to a minimum?

To investigate memory leaks, I set up a route that runs global.gc() on every POST /gc

 app.post('/gc', function(req, res){ global.gc(); }); 

However, I noticed that if I spam this request, it reduces memory usage more and more every time. Shouldn't you call global.gc() once to reduce memory to a minimum ?

If so, why does a call reduce memory several times in a row with each call ?

(I am using Node.js v0.12)

+6
source share
1 answer

At a very high level, the V8 divides the GC into two parts. We are looking for garbage to collect and actually collect garbage. The gc() call is only performed in the second part, collecting garbage already found.

0
source

All Articles