Skip to content
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

cli: add --expose-gc flag available to NODE_OPTIONS #53078

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

juanarbol
Copy link
Member

This commits allows users to send --expose-gc via NODE_OPTIONS environment variable.

Using node --expose-gc is possible but via NODE_OPTIONS won't work.

NODE_OPTIONS='--expose-gc' node
node: --expose-gc is not allowed in NODE_OPTIONS

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 21, 2024
@juanarbol juanarbol added cli Issues and PRs related to the Node.js command line interface. request-ci Add this label to start a Jenkins CI on a PR. labels May 21, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 21, 2024
@nodejs-github-bot

This comment was marked as outdated.

@juanarbol
Copy link
Member Author

Whoops, this needs some tweaks. I'll work on them tomorrow

@nodejs-github-bot
Copy link
Collaborator

@juanarbol juanarbol added the request-ci Add this label to start a Jenkins CI on a PR. label May 22, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 22, 2024
@nodejs-github-bot
Copy link
Collaborator

doc/api/cli.md Outdated

```js
// If the --expose-gc flag is provided, V8 will expose the garbage collector
// allowing users to trigger garbage collection on demand.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer that we don't document this because what "trigger garbage collection" means is usually not what users expected (the kind of garbage collection that gc() does isn't very eager, it can leave unreachable objects around, which isn't a bug because it's only invented for V8's tests and only cater to what their tests need, which may on the other hand require a single round of GC. But that can be very surprising to users expecting or even relying on it to "clean up all the garbage in the heap if they are already unreachable"). We already saw that happenning to Jest's leak detector (even after doing gc() 10 times it can still produce false positives) #48510 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove the docs, or specify that is for testing purposes only and it is not meant to be ran in productive environments. Or do u have any suggestion for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to not documenting as Joyee suggests.

@targos
Copy link
Member

targos commented May 22, 2024

With #53078 (comment) in mind, is there a legitimate use case for the flag?

@juanarbol
Copy link
Member Author

With #53078 (comment) in mind, is there a legitimate use case for the flag?

Debugging heap size.

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the documentation removed.

@juanarbol
Copy link
Member Author

Ok, docs are gone now

doc/api/cli.md Outdated Show resolved Hide resolved
This commits allows users to send `--expose-gc` via `NODE_OPTIONS`
environment variable.

Using `node --expose-gc` is possible but via `NODE_OPTIONS` won't
work.

```sh
NODE_OPTIONS='--expose-gc' node
node: --expose-gc is not allowed in NODE_OPTIONS
```

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
@juanarbol juanarbol added the request-ci Add this label to start a Jenkins CI on a PR. label May 27, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 27, 2024
@nodejs-github-bot
Copy link
Collaborator

@juanarbol juanarbol added the request-ci Add this label to start a Jenkins CI on a PR. label May 28, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 28, 2024
@nodejs-github-bot
Copy link
Collaborator

@juanarbol juanarbol added the request-ci Add this label to start a Jenkins CI on a PR. label May 30, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 30, 2024
@nodejs-github-bot
Copy link
Collaborator

@juanarbol juanarbol added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 3, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 3, 2024
@nodejs-github-bot
Copy link
Collaborator

@juanarbol juanarbol added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 4, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 4, 2024
@nodejs-github-bot nodejs-github-bot merged commit b26a260 into nodejs:main Jun 4, 2024
65 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in b26a260

RafaelGSS pushed a commit that referenced this pull request Jun 7, 2024
This commits allows users to send `--expose-gc` via `NODE_OPTIONS`
environment variable.

Using `node --expose-gc` is possible but via `NODE_OPTIONS` won't
work.

```sh
NODE_OPTIONS='--expose-gc' node
node: --expose-gc is not allowed in NODE_OPTIONS
```

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
PR-URL: #53078
Reviewed-By: Tierney Cyren <hello@bnb.im>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
@RafaelGSS RafaelGSS mentioned this pull request Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. cli Issues and PRs related to the Node.js command line interface. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants