-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: modified docs to reflect how to invoke gc on Wrapping C++ objects #20431
Conversation
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: #19876
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: #19876
@nodejs/addon-api Is this information we'd want to include? Since these are V8 internal flags, @nodejs/v8 also might have opinions on whether we should include this information in our docs or not. If we do want to include it, the text could benefit from a bit of editing. Maybe @nodejs/documentation can offer some suggested alternative wording etc. |
Prior conversation for context: #20269 |
Personally I don't think using Can't we write these demo cases or tests in a way that at the end it keeps allocating until the destroy callback fires? Failing tests become timeouts, which is not ideal, but aside from that this is nicer than recommending V8's debugging flags. |
Conclusion of previous discussions (#20269 (comment)) is that we shouldn't document something like allocating a large number of objects to trigger GC mainly because it is going to official docs and coding a bad practice that could be misleading. Therefore we could document v8 flags highlighting those are only for testing purposes and provided by V8 would be enough. |
doc/api/addons.md
Outdated
` --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. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?:
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.
Or if that's too mysterious, maybe this?:
The destructor for a wrapper object will run when the object is
garbage-collected.
Leave it as an exercise for the reader to figure out how to force garbage collection for testing purposes. People can find that in blog posts and StackOverflow etc. (For example, https://stackoverflow.com/q/27321997/436641.) But we don't have to document it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with leaving reader to figure it out since we are not recommending to use command line flags outside of testing. First options is informative and I'll proceed with that.
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
@bnoordhuis @hashseed PTAL |
@hashseed I think for Regarding this PR, I like the idea but it’s probably not very meaningful to say “There are undocumented flags that do exactly what you need right now, please don’t look them up because that’s a bad thing”. I’d be okay with officially recommending |
Ping... what's the status on this one? |
It might be good to hear what @hashseed thinks of the above – again, I’m really not saying I’m a fan of us effectively making a V8 flag public API, but we have to face the fact that it effectively is. |
doc/api/addons.md
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: subjected
-> subject
I'm happy with the current wording. |
Hmmm, the same unrelated TLS test failing three times. Let's try a fresh run rather than a Replay and see if that clears up some git stuff leftover from another run or something weird like that which might be causing it. Yeah, I'm making it up. Let's try it anyway: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/920/ |
That time, it was a hard build failure. I've pinged build folks to take a look and hopefully it will be fixed soon and we can try again. Sorry about the delay. |
Looks like I kicked off the job incorrectly. Let's try again: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/926/ |
Giving up on lite CI, going for full CI: https://ci.nodejs.org/job/node-test-pull-request/17299/ |
Windows rebuild: https://ci.nodejs.org/job/node-test-commit-windows-fanned/20844/ |
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: nodejs#19876 PR-URL: nodejs#20431 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org>
Finally... Landed in a1381fa |
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: #19876 PR-URL: #20431 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org>
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: #19876 PR-URL: #20431 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org>
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: #19876
Checklist