From 150e8c4caa3873c9c9edece0010cd30796ca6a82 Mon Sep 17 00:00:00 2001 From: isurusiri Date: Mon, 30 Apr 2018 21:43:29 +0530 Subject: [PATCH 1/4] doc: modified docs to instruct how to invoke gc on Wrapping C++ objects 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 --- doc/api/addons.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/api/addons.md b/doc/api/addons.md index 46bc1e7522c505..24a03f520009bf 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -708,6 +708,13 @@ console.log(obj.plusOne()); // Prints: 13 ``` +When it comes to destructing wrapper objects, garbage collector can execute +forcefully using V8 command line flags ` --gc_global ` and ` gc_interval `, +where ` --gc_global ` forces V8 to perform a full garbage collection and +` gc_interval ` forces V8 to perform garbage collection after a given amount +of allocations. Although, it is recommended to limit V8 command line flags +for testing purposes only, since these are primarily debug flags. + ### Factory of wrapped objects Alternatively, it is possible to use a factory pattern to avoid explicitly From ea508f7b2c95ceb98ac983a87ce76d851c6f2a4b Mon Sep 17 00:00:00 2001 From: isurusiri Date: Mon, 30 Apr 2018 21:54:15 +0530 Subject: [PATCH 2/4] doc: modified docs to instruct how to invoke gc on Wrapping C++ objects 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 --- doc/api/addons.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index 24a03f520009bf..9eb395e91d25bf 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -709,9 +709,9 @@ console.log(obj.plusOne()); ``` When it comes to destructing wrapper objects, garbage collector can execute -forcefully using V8 command line flags ` --gc_global ` and ` gc_interval `, +forcefully using V8 command line flags ` --gc_global ` and ` --gc_interval `, where ` --gc_global ` forces V8 to perform a full garbage collection and -` gc_interval ` forces V8 to perform garbage collection after a given amount +` --gc_interval ` forces V8 to perform garbage collection after a given amount of allocations. Although, it is recommended to limit V8 command line flags for testing purposes only, since these are primarily debug flags. From a8fd24fd83612524c2ebc91fca75c9835fd9f0f2 Mon Sep 17 00:00:00 2001 From: isurusiri Date: Thu, 3 May 2018 06:27:49 +0530 Subject: [PATCH 3/4] doc: modified docs to instruct how to invoke gc on Wrapping C++ objects Currently the documentation for Wrapping C++ Objects doesn't explain how the destructor executes when garbage-collector runs. This commit includes a modification to docs that instructs how the destructor for wrapper objects will run and options available to test destructor Fixes: http://github.com/nodejs/node/issues/19876 --- doc/api/addons.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index 9eb395e91d25bf..e12c2e4a4d007d 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -708,12 +708,12 @@ console.log(obj.plusOne()); // Prints: 13 ``` -When it comes to destructing wrapper objects, garbage collector can execute -forcefully using V8 command line flags ` --gc_global ` and ` --gc_interval `, -where ` --gc_global ` forces V8 to perform a full garbage collection and -` --gc_interval ` forces V8 to perform garbage collection after a given amount -of allocations. Although, it is recommended to limit V8 command line flags -for testing purposes only, since these are primarily debug flags. +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 subjected 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 From 1056c8f281257f49581958da92360fee8843fbc1 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 18 Sep 2018 06:46:03 -0700 Subject: [PATCH 4/4] squash! nit fix --- doc/api/addons.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index e12c2e4a4d007d..e3fcbe34b6988c 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -711,7 +711,7 @@ console.log(obj.plusOne()); 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 subjected to change +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.