I found the related problem here
But still don't got the real answer for this. :( So, How to reduce to minimum memory with global.gc() in nodejs? should I spam global.gc() function to reduce?
Instead of forcing the garbage collector to run, you should first identify if you actually have a memory leak by using various tools (e.g. node's built-in inspector, heapdump module, etc.) available for node that allow you to detect such leaks.
It's entirely possible that it appears there is a leak when there isn't, due to how V8's garbage collector works (it is generally lazy because GC is not exactly a cheap operation CPU usage-wise).
Also, you can limit the amount of memory used by V8 via the --max-old-space-size=xxxx command-line argument (where xxxx is the amount of memory in megabytes). This can also be helpful in more quickly determining whether you have a legitimate memory leak.
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