To investigate memory leaks, I have setup a route that triggers global.gc()
at every POST /gc
app.post('/gc', function(req, res){
global.gc();
});
However, I've noticed that if I spam this request, it reduces the memory usage more and more each time. Shouldn't calling global.gc()
once is enough to reduce the memory to minimum?
If so, why does calling multiple times consecutively reduces memory at every call?
(I'm using Node.js v0.12)
At a very high level, V8 splits up GC into two parts. Looking for garbage to collect, and actually collecting the garbage. Calling gc()
only does the second part, collecting already-found garbage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With