-
-
Save bnoordhuis/8530cceca335b7a0469c to your computer and use it in GitHub Desktop.
Context dispose hint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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