Skip to content
Merged
Prev Previous commit
Next Next commit
doc: fix linting and doc issues
  • Loading branch information
Asaf-Federman committed Jul 23, 2025
commit b919043d35a82456694ca426afb2c3614d318ae0
32 changes: 16 additions & 16 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,22 @@ changes:

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

### `--max-old-space-size-percentage=PERCENTAGE`

Sets the max memory size of V8's old memory section as a percentage of available system memory.
This flag takes precedence over `--max-old-space-size` when both are specified.

The `PERCENTAGE` parameter must be a number greater than 0 and up to 100. representing the percentage
of available system memory to allocate to the V8 heap.

```bash
# Using 50% of available system memory
node --max-old-space-size-percentage=50 index.js

# Using 75% of available system memory
node --max-old-space-size-percentage=75 index.js
```

### `--napi-modules`

<!-- YAML
Expand Down Expand Up @@ -3860,22 +3876,6 @@ documented here:

### `--jitless`

### `--max-old-space-size-percentage=PERCENTAGE`

Sets the max memory size of V8's old memory section as a percentage of available system memory.
This flag takes precedence over `--max-old-space-size` when both are specified.

The `PERCENTAGE` parameter must be a number greater than 0 and up to 100. representing the percentage
of available system memory to allocate to the V8 heap.

```bash
# Using 50% of available system memory
node --max-old-space-size-percentage=50 index.js

# Using 75% of available system memory
node --max-old-space-size-percentage=75 index.js
```

<!-- Anchor to make sure old links find a target -->

<a id="--max-old-space-sizesize-in-megabytes"></a>
Expand Down
10 changes: 10 additions & 0 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,16 @@ The file used to store localStorage data.
.It Fl -max-http-header-size Ns = Ns Ar size
Specify the maximum size of HTTP headers in bytes. Defaults to 16 KiB.
.
.It Fl -max-old-space-size-percentage Ns = Ns Ar percentage
Sets the max memory size of V8's old memory section as a percentage of available system memory.
This flag takes precedence over
.Fl -max-old-space-size
when both are specified.
The
.Ar percentage
parameter must be a number greater than 0 and up to 100, representing the percentage
of available system memory to allocate to the V8 heap.
.
.It Fl -napi-modules
This option is a no-op.
It is kept for compatibility.
Expand Down
11 changes: 5 additions & 6 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -765,12 +765,11 @@ static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
v8_args.emplace_back("--harmony-import-attributes");
}

if (!per_process::cli_options->
per_isolate->
max_old_space_size_percentage.empty()) {
v8_args.emplace_back("--max_old_space_size=" +
per_process::cli_options->per_isolate->
max_old_space_size);
if (!per_process::cli_options->per_isolate->max_old_space_size_percentage
.empty()) {
v8_args.emplace_back(
"--max_old_space_size=" +
per_process::cli_options->per_isolate->max_old_space_size);
}

auto env_opts = per_process::cli_options->per_isolate->per_env;
Expand Down
7 changes: 4 additions & 3 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ void PerIsolateOptions::HandleMaxOldSpaceSizePercentage(
// Validate the percentage value
if (*end_ptr != '\0' || percentage <= 0.0 || percentage > 100.0) {
errors->push_back("--max-old-space-size-percentage must be greater "
"than 0 and up to 100. Got: " + original_input_for_error);
"than 0 and up to 100. Got: " +
original_input_for_error);
return;
}

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

// Use constrained memory if available, otherwise use total memory
size_t available_memory = (constrained_memory > 0) ? constrained_memory
: total_memory;
size_t available_memory =
(constrained_memory > 0) ? constrained_memory : total_memory;

// Convert to MB and calculate the percentage
size_t memory_mb = available_memory / (1024 * 1024);
Expand Down
5 changes: 2 additions & 3 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,8 @@ class PerIsolateOptions : public Options {
inline EnvironmentOptions* get_per_env_options();
void CheckOptions(std::vector<std::string>* errors,
std::vector<std::string>* argv) override;
void HandleMaxOldSpaceSizePercentage(
std::vector<std::string>* errors,
std::string* max_old_space_size);
void HandleMaxOldSpaceSizePercentage(std::vector<std::string>* errors,
std::string* max_old_space_size);

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

Expand Down