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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/api/v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ does not include memory that has been allocated but not yet used.

`heap_size_limit` The value of heap\_size\_limit is the maximum size of the V8
heap, in bytes (either the default limit, determined by system resources, or
the value passed to the `--max_old_space_size` option).
the value passed to the `--max-old-space-size` option plus heap's semi space plus
heap's young generation space).
Comment on lines +222 to +223
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.


`malloced_memory` The value of malloced\_memory is the number of bytes allocated
through `malloc` by V8.
Expand Down