Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable GC #462

Closed
jaipradeesh opened this issue Jan 24, 2017 · 9 comments

Comments

@jaipradeesh
Copy link

commented Jan 24, 2017

I am looking for something similar to https://docs.python.org/2/library/gc.html#gc.disable (or) alternative flag combination to achieve the below mentioned.

'A node process to run until it reaches a defined RSS without GC interference.'

@bnoordhuis

This comment has been minimized.

Copy link
Member

commented Jan 24, 2017

You can't disable it but you can try setting the --max_*_space_size=... flags (see node --v8-options) high enough that garbage collection never happens. See also --trace_gc.

There is no equivalent to python's gc.disable(). Cpython mainly uses reference counting, with the garbage collector as a fallback mechanism for collecting cyclic object graphs. Node/V8 always uses generational GC.

@bnoordhuis bnoordhuis closed this Jan 24, 2017

@jaipradeesh

This comment has been minimized.

Copy link
Author

commented Jan 24, 2017

@bnoordhuis

This comment has been minimized.

Copy link
Member

commented Jan 24, 2017

@dolftax Yes.

@jaipradeesh

This comment has been minimized.

Copy link
Author

commented Jan 29, 2017

➜ node --nouse_idle_notification --trace_gc --max-old-space-size=1000 --max-semi-space-size=64 example.js
[4465:0x3558ae0]      119 ms: Scavenge 3.2 (9.0) -> 2.9 (10.0) MB, 1.2 / 0.0 ms  allocation failure 

@bnoordhuis I have set the max-old-space-size and max-semi-space-size high enough and if you look below, the RSS is no-way near the constraints set. Why is the GC still trying to run?

➜ ps aux | grep node 
dolftax   4465  0.3  0.7 881664 29460 pts/0    Sl+  21:43   0:01 node --nouse_idle_notification --trace_gc --max-old-space-size=1000 --max-semi-space-size=64 example.js

.. where RSS is 29460 bytes

@bnoordhuis

This comment has been minimized.

Copy link
Member

commented Jan 30, 2017

Perhaps you also need to pass --noconcurrent_sweeping. If that doesn't help, I think the conclusion has to be that it can't be done.

@jaipradeesh

This comment has been minimized.

Copy link
Author

commented Jan 30, 2017

➜ node --nouse_idle_notification --trace_gc --max-old-space-size=1000 --max-semi-space-size=64 --noconcurrent_sweeping example.js
[10948:0x3712ae0]      119 ms: Scavenge 3.2 (9.0) -> 2.9 (10.0) MB, 1.2 / 0.0 ms  allocation failure 
[10948:0x3712ae0]      151 ms: Scavenge 3.5 (10.0) -> 3.5 (11.0) MB, 2.4 / 0.0 ms  allocation failure 
9 workers forked/spawned
[10967:0x2f4db20]      271 ms: Scavenge 3.1 (9.0) -> 2.8 (10.0) MB, 1.9 / 0.0 ms  allocation failure 

Thus, concluded.

@jaipradeesh

This comment has been minimized.

Copy link
Author

commented Jan 30, 2017

@bnoordhuis I managed to get the GC running as required.

node --max-old-space-size=1000 --max-semi-space-size=512 --noconcurrent_sweeping example.js

.. did wait for the max old space size to reach 1000 MB before running Mark Sweep. 😸

@Shahor

This comment has been minimized.

Copy link

commented Jun 2, 2018

Hello there,

For a test I was trying to do exactly this and tried with your solution but somehow I see the GC always running even though I haven't reached the limits I imposed... so I suppose either:

  • it has changed since, and can't be stopped that way on newer node versions
  • I'm doing something wrong.

If you guys have any info on this I would be super interested :)

@emersoncantalice

This comment has been minimized.

Copy link

commented Aug 24, 2018

Any success in disabling the GC in any way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.