Is there any way to explicitly disable GC runs (at least most time-consuming ones, like GC interrupts in old space) during the specified period of time, while executing some code sensitive to delays? Something like this:
disableGc();
runCodeWithoutDelays();
enableGc();
Probably using some node options, or native modules? Or can I write my own module, is there an API in V8 for that?
Since the collector supplements the reference counting already used in Python, you can disable the collector if you are sure your program does not create reference cycles. Automatic collection can be disabled by calling gc. disable() .
Luckily for you, Node. js comes with a garbage collector, and you don't need to manually manage memory allocation.
Some high-level languages, such as JavaScript, utilize a form of automatic memory management known as garbage collection (GC).
The event loop is what allows Node. js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background.
As far as I know you can't manually stop v8's garbage collector, the only thing you can do is start the gc process manually running global.gc()
but not stopping v8's process.
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