Skip to content

Commit f8be4b5

Browse files
committed
doc: fix linting and doc issues
1 parent b8ec422 commit f8be4b5

5 files changed

Lines changed: 37 additions & 28 deletions

File tree

doc/api/cli.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,22 @@ changes:
17261726

17271727
Specify the maximum size, in bytes, of HTTP headers. Defaults to 16 KiB.
17281728

1729+
### `--max-old-space-size-percentage=PERCENTAGE`
1730+
1731+
Sets the max memory size of V8's old memory section as a percentage of available system memory.
1732+
This flag takes precedence over `--max-old-space-size` when both are specified.
1733+
1734+
The `PERCENTAGE` parameter must be a number greater than 0 and up to 100. representing the percentage
1735+
of available system memory to allocate to the V8 heap.
1736+
1737+
```bash
1738+
# Using 50% of available system memory
1739+
node --max-old-space-size-percentage=50 index.js
1740+
1741+
# Using 75% of available system memory
1742+
node --max-old-space-size-percentage=75 index.js
1743+
```
1744+
17291745
### `--napi-modules`
17301746

17311747
<!-- YAML
@@ -3871,22 +3887,6 @@ documented here:
38713887

38723888
### `--jitless`
38733889

3874-
### `--max-old-space-size-percentage=PERCENTAGE`
3875-
3876-
Sets the max memory size of V8's old memory section as a percentage of available system memory.
3877-
This flag takes precedence over `--max-old-space-size` when both are specified.
3878-
3879-
The `PERCENTAGE` parameter must be a number greater than 0 and up to 100. representing the percentage
3880-
of available system memory to allocate to the V8 heap.
3881-
3882-
```bash
3883-
# Using 50% of available system memory
3884-
node --max-old-space-size-percentage=50 index.js
3885-
3886-
# Using 75% of available system memory
3887-
node --max-old-space-size-percentage=75 index.js
3888-
```
3889-
38903890
<!-- Anchor to make sure old links find a target -->
38913891

38923892
<a id="--max-old-space-sizesize-in-megabytes"></a>

doc/node.1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,16 @@ The file used to store localStorage data.
338338
.It Fl -max-http-header-size Ns = Ns Ar size
339339
Specify the maximum size of HTTP headers in bytes. Defaults to 16 KiB.
340340
.
341+
.It Fl -max-old-space-size-percentage Ns = Ns Ar percentage
342+
Sets the max memory size of V8's old memory section as a percentage of available system memory.
343+
This flag takes precedence over
344+
.Fl -max-old-space-size
345+
when both are specified.
346+
The
347+
.Ar percentage
348+
parameter must be a number greater than 0 and up to 100, representing the percentage
349+
of available system memory to allocate to the V8 heap.
350+
.
341351
.It Fl -napi-modules
342352
This option is a no-op.
343353
It is kept for compatibility.

src/node.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,12 +765,11 @@ static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
765765
v8_args.emplace_back("--harmony-import-attributes");
766766
}
767767

768-
if (!per_process::cli_options->
769-
per_isolate->
770-
max_old_space_size_percentage.empty()) {
771-
v8_args.emplace_back("--max_old_space_size=" +
772-
per_process::cli_options->per_isolate->
773-
max_old_space_size);
768+
if (!per_process::cli_options->per_isolate->max_old_space_size_percentage
769+
.empty()) {
770+
v8_args.emplace_back(
771+
"--max_old_space_size=" +
772+
per_process::cli_options->per_isolate->max_old_space_size);
774773
}
775774

776775
auto env_opts = per_process::cli_options->per_isolate->per_env;

src/node_options.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ void PerIsolateOptions::HandleMaxOldSpaceSizePercentage(
126126
// Validate the percentage value
127127
if (*end_ptr != '\0' || percentage <= 0.0 || percentage > 100.0) {
128128
errors->push_back("--max-old-space-size-percentage must be greater "
129-
"than 0 and up to 100. Got: " + original_input_for_error);
129+
"than 0 and up to 100. Got: " +
130+
original_input_for_error);
130131
return;
131132
}
132133

@@ -135,8 +136,8 @@ void PerIsolateOptions::HandleMaxOldSpaceSizePercentage(
135136
size_t constrained_memory = uv_get_constrained_memory();
136137

137138
// Use constrained memory if available, otherwise use total memory
138-
size_t available_memory = (constrained_memory > 0) ? constrained_memory
139-
: total_memory;
139+
size_t available_memory =
140+
(constrained_memory > 0) ? constrained_memory : total_memory;
140141

141142
// Convert to MB and calculate the percentage
142143
size_t memory_mb = available_memory / (1024 * 1024);

src/node_options.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,8 @@ class PerIsolateOptions : public Options {
295295
inline EnvironmentOptions* get_per_env_options();
296296
void CheckOptions(std::vector<std::string>* errors,
297297
std::vector<std::string>* argv) override;
298-
void HandleMaxOldSpaceSizePercentage(
299-
std::vector<std::string>* errors,
300-
std::string* max_old_space_size);
298+
void HandleMaxOldSpaceSizePercentage(std::vector<std::string>* errors,
299+
std::string* max_old_space_size);
301300

302301
inline std::shared_ptr<PerIsolateOptions> Clone() const;
303302

0 commit comments

Comments
 (0)