Managing/Controlling Garbage collection in Node Process

NodeJS processes have automatic Garbage collection routine calls, but its aggressive by default and it will always try to use the slightest of idle time and this can lead to some performance drawbacks for certain applications.

In such a case its good to use –-nouse_idle_notification flag while starting node process. What this does is instruct the GC to ignore idle notifications from nodejs and just run at lesser aggressive time intervals.

Manual call to gc() the garbage collector!

There is also option to get a global function inside your javascript code in node process… the gc() call. This is not available by default and you have to set a flag called –expose_gc while starting the node process. What this does is offer the programmer a global function called gc() that can be called inside code which is logically a idling/timed wait kind of place or concluding place of a logic inside code.

 

Leave a Reply