Skip to content

Instantly share code, notes, and snippets.

@bnoordhuis
Created October 24, 2013 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bnoordhuis/8530cceca335b7a0469c to your computer and use it in GitHub Desktop.
Save bnoordhuis/8530cceca335b7a0469c to your computer and use it in GitHub Desktop.
Context dispose hint
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index f78f49f..718adb4 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -83,6 +83,15 @@ class ContextifyContext {
context_.Dispose();
proxy_global_.Dispose();
sandbox_.Dispose();
+ // To prevent the DAG from this context from sticking around for too long,
+ // we give some strong hints to V8 that now is a good time to do a full GC.
+ // ContextDisposedNotification() makes IdleNotification() flush the current
+ // generation of ICs, which would otherwise prevent a full reclaim.
+ // Retiring the ICs means we set off a cascade of deoptimizations in the
+ // remaining contexts but there is nothing we can do about that. If we
+ // don't take action, parts of the context may stick around indefinitely.
+ V8::ContextDisposedNotification();
+ V8::IdleNotification();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment