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

doc: correct definition of v8.getHeapStatistics().heap_size_limit #57029

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

inwenis
Copy link

@inwenis inwenis commented Feb 13, 2025

No description provided.

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label Feb 13, 2025
@inwenis inwenis changed the title Heap docs doc: correct definition of v8.getHeapStatistics().heap_size_limit Feb 13, 2025
Comment on lines +222 to +223
the value passed to the `--max-old-space-size` option plus heap's semi space plus
heap's young generation space).
Copy link
Member

Choose a reason for hiding this comment

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

The semi space and young generation space are referring to the same concept. I think a more straightforward hint here will be pointing to --max-heap-size:

Suggested change
the value passed to the `--max-old-space-size` option plus heap's semi space plus
heap's young generation space).
the value passed to the `--max-heap-size` option).

Though, both --max_semi_space_size and --max_old_space_size take precedence over --max-heap-size option, and are hinted via node --v8-options.

Copy link
Author

Choose a reason for hiding this comment

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

https://nodejs.org/api/cli.html does not describe --max-heap-size.

The semi space and young generation space are referring to the same concept - I agree
But the docs below say heap=old-space + semi-space + 3*semi-space (young generation) however my tests showed that this math doesn't hold up with reality.
https://nodejs.org/api/cli.html#--max-semi-space-sizesize-in-mib

I would love for the docs to be exhaustive and non ambiguous.
It seemed to me that the least ambiguous definition of the heap size is the sum of its "parts".

Copy link
Member

Choose a reason for hiding this comment

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

That document refers to the large new object space, whose size is implied with the --max-semi-space-size, is also counted in the formula: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/heap/heap.cc;l=203-208?q=Heap::MaxReserved

There are many factors in V8 that can change the assumed formula of the heap limit size, like the conditions in the link above. Given that these flags are maintained in V8, rather than node, I'd still suggest refer to --max-heap-size, which is the most striaghtforward to set the general limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants