GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: modified docs to reflect how to invoke gc on Wrapping C++ objects by isurusiri · Pull Request #20431 · nodejs/node

Conversation

@isurusiri

@isurusiri isurusiri commented Apr 30, 2018

Copy link
Copy Markdown
Contributor

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
  • documentation is changed or added
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
isurusiri added 2 commits April 30, 2018 21:43
@isurusiri
doc: modified docs to instruct how to invoke gc on Wrapping C++ objects
150e8c4
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
@isurusiri
doc: modified docs to instruct how to invoke gc on Wrapping C++ objects
ea508f7
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-github-bot nodejs-github-bot added addons Issues and PRs related to native addons. doc Issues and PRs related to Node.js documentation. labels Apr 30, 2018
@vsemozhetbyt

vsemozhetbyt commented May 1, 2018

Copy link
Copy Markdown
Contributor

CI-lite: https://ci.nodejs.org/job/node-test-pull-request-lite/642/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented May 1, 2018

Copy link
Copy Markdown
Member

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented May 1, 2018

Copy link
Copy Markdown
Member

Prior conversation for context: #20269

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hashseed

hashseed commented May 1, 2018

Copy link
Copy Markdown
Member

Personally I don't think using --gc-global and --gc-interval is any better than triggering gc directly via gc(). None of these are public APIs. Though people are probably more likely to avoid --gc-inteval since it seriously degrades performance.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@isurusiri

isurusiri commented May 2, 2018

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott reviewed May 2, 2018
View reviewed changes
Comment thread doc/api/addons.md
` --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.

@Trott Trott May 2, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@isurusiri isurusiri May 3, 2018

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@isurusiri
doc: modified docs to instruct how to invoke gc on Wrapping C++ objects
a8fd24f
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
@Trott

Trott commented May 3, 2018

Copy link
Copy Markdown
Member

@bnoordhuis @hashseed PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented May 6, 2018

Copy link
Copy Markdown
Member

@hashseed I think for --expose-gc not having to be considered public API the ship has sailed a long time ago. Not saying that’s a good thing – I just think it’s something we’re locked into. A lot of test suites for Node addons use it in the way described here, to the degree that some test runners/frameworks have explicit builtin support for making tests run with this flag (e.g. mocha).

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 --expose-gc, but don’t really want to do that over the V8 team’s head either.

BridgeAR reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes May 23, 2018
View reviewed changes
@BridgeAR

BridgeAR commented May 29, 2018

Copy link
Copy Markdown
Member

@hashseed I think @addaleax has a good point here. That flag is indeed pretty commonly used.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Sep 10, 2018

Copy link
Copy Markdown
Member

Ping... what's the status on this one?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell added the stalled Issues and PRs manually marked as stalled and scheduled for automatic closure. label Sep 10, 2018
@addaleax

addaleax commented Sep 11, 2018

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott reviewed Sep 17, 2018
View reviewed changes
Comment thread 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

@Trott Trott Sep 17, 2018

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hashseed

hashseed commented Sep 17, 2018

Copy link
Copy Markdown
Member

I'm happy with the current wording.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hashseed
hashseed approved these changes Sep 17, 2018
View reviewed changes
@Trott

Trott commented Sep 17, 2018

Copy link
Copy Markdown
Member

Lite CI: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/902/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 17, 2018
@addaleax

addaleax commented Sep 17, 2018

Copy link
Copy Markdown
Member

CI again: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/910/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Sep 18, 2018

Copy link
Copy Markdown
Member

Ci again again: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/919/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Sep 18, 2018

Copy link
Copy Markdown
Member

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/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Sep 18, 2018

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Sep 18, 2018

Copy link
Copy Markdown
Member

Looks like I kicked off the job incorrectly. Let's try again: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/926/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott
squash! nit fix
1056c8f
@Trott

Trott commented Sep 18, 2018

Copy link
Copy Markdown
Member

Giving up on lite CI, going for full CI: https://ci.nodejs.org/job/node-test-pull-request/17299/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Sep 19, 2018

Copy link
Copy Markdown
Member

Windows rebuild: https://ci.nodejs.org/job/node-test-commit-windows-fanned/20844/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott pushed a commit to Trott/io.js that referenced this pull request Sep 19, 2018
@isurusiri @Trott
doc: explain how to invoke gc
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: nodejs#19876

PR-URL: nodejs#20431
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Yang Guo <[email protected]>
@Trott

Trott commented Sep 19, 2018

Copy link
Copy Markdown
Member

Finally...

Landed in a1381fa

isurusiri reacted with thumbs up emoji isurusiri reacted with laugh emoji
All reactions
  • 👍 1 reaction
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott closed this Sep 19, 2018
@targos targos mentioned this pull request Sep 19, 2018
Release proposal: v10.11.0 #22932
Merged
targos pushed a commit that referenced this pull request Sep 19, 2018
@isurusiri @targos
doc: explain how to invoke gc
d46ce65
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 <[email protected]>
Reviewed-By: Yang Guo <[email protected]>
targos pushed a commit that referenced this pull request Sep 20, 2018
@isurusiri @targos
doc: explain how to invoke gc
6ed5845
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 <[email protected]>
Reviewed-By: Yang Guo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Trott Trott Trott left review comments
@jasnell jasnell jasnell approved these changes
+1 more reviewer
@hashseed hashseed hashseed approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

addons Issues and PRs related to native addons. author ready PRs with CI started, the required approvals, and no outstanding review comments. doc Issues and PRs related to Node.js documentation. stalled Issues and PRs manually marked as stalled and scheduled for automatic closure.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@isurusiri @vsemozhetbyt @Trott @hashseed @addaleax @BridgeAR @jasnell @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.