From d46ce6559f1ccf05e8cfc9b8c97a307ac0aa54d9 Mon Sep 17 00:00:00 2001 From: isurusiri Date: Mon, 30 Apr 2018 21:43:29 +0530 Subject: [PATCH] doc: explain how to invoke gc Currently the documentation for Wrapping C++ Objects doesn't explain how to destruct an object by explicitly invoking the garbage collector. This commit includes a modification to docs that explains how to force the garbage collector to clear objects using V8's command line flags. Fixes: https://github.com/nodejs/node/issues/19876 PR-URL: https://github.com/nodejs/node/pull/20431 Reviewed-By: James M Snell Reviewed-By: Yang Guo --- doc/api/addons.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/api/addons.md b/doc/api/addons.md index 483f2ad27d7feb..5e06336a85a4a0 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -848,6 +848,13 @@ console.log(obj.plusOne()); // Prints: 13 ``` +The destructor for a wrapper object will run when the object is +garbage-collected. For destructor testing, there are command-line flags that +can be used to make it possible to force garbage collection. These flags are +provided by the underlying V8 JavaScript engine. They are subject to change +or removal at any time. They are not documented by Node.js or V8, and they +should never be used outside of testing. + ### Factory of wrapped objects Alternatively, it is possible to use a factory pattern to avoid explicitly