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 <jasnell@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
This commit is contained in:
isurusiri 2018-04-30 21:43:29 +05:30 committed by Rich Trott
parent e6d0ced7bb
commit a1381fab8a

View File

@ -848,6 +848,13 @@ console.log(obj.plusOne());
// Prints: 13 // 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 ### Factory of wrapped objects
Alternatively, it is possible to use a factory pattern to avoid explicitly Alternatively, it is possible to use a factory pattern to avoid explicitly