A
A
artch2015-10-29 10:17:38
JavaScript
artch, 2015-10-29 10:17:38

Is it possible to temporarily disable GC in node.js when executing a certain piece of code?

When executing latency-sensitive code, you want to temporarily disable the GC and enable it back, something like this:

disableGc();
runCodeWithoutDelays();
enableGc();

Is it possible to do this with some node.js flags, native modules? Or can I write my own module for this, is there the necessary API in V8?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Shemsedinov, 2015-10-29
@MarcusAurelius

No, but you can turn off the automatic garbage collector with command line switches and call it yourself, as needed:
node --nouse-idle-notification --expose-gc program.js
Now the gc() function will appear in the global, which you need to call.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question