Skip to content

Commit

Permalink
cli: add --heap-prof flag available to NODE_OPTIONS
Browse files Browse the repository at this point in the history
Fixes: #54257
Signed-off-by: Juan José Arboleda <[email protected]>
  • Loading branch information
juanarbol committed Oct 14, 2024
1 parent 10addb0 commit 0a28ac5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3075,6 +3075,10 @@ one is included in the list below.
* `--force-fips`
* `--force-node-api-uncaught-exceptions-policy`
* `--frozen-intrinsics`
* `--heap-prof-dir`
* `--heap-prof-interval`
* `--heap-prof-name`
* `--heap-prof`
* `--heapsnapshot-near-heap-limit`
* `--heapsnapshot-signal`
* `--http-parser`
Expand Down
12 changes: 8 additions & 4 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -617,19 +617,23 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"Start the V8 heap profiler on start up, and write the heap profile "
"to disk before exit. If --heap-prof-dir is not specified, write "
"the profile to the current working directory.",
&EnvironmentOptions::heap_prof);
&EnvironmentOptions::heap_prof,
kAllowedInEnvvar);
AddOption("--heap-prof-name",
"specified file name of the V8 heap profile generated with "
"--heap-prof",
&EnvironmentOptions::heap_prof_name);
&EnvironmentOptions::heap_prof_name,
kAllowedInEnvvar);
AddOption("--heap-prof-dir",
"Directory where the V8 heap profiles generated by --heap-prof "
"will be placed.",
&EnvironmentOptions::heap_prof_dir);
&EnvironmentOptions::heap_prof_dir,
kAllowedInEnvvar);
AddOption("--heap-prof-interval",
"specified sampling interval in bytes for the V8 heap "
"profile generated with --heap-prof. (default: 512 * 1024)",
&EnvironmentOptions::heap_prof_interval);
&EnvironmentOptions::heap_prof_interval,
kAllowedInEnvvar);
#endif // HAVE_INSPECTOR
AddOption("--max-http-header-size",
"set the maximum size of HTTP headers (default: 16384 (16KB))",
Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-cli-node-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ if (common.hasCrypto) {
expectNoWorker('--openssl-config=_ossl_cfg', 'B\n');
}

// Needs inspector enabled.
// Refs: https://github.com/nodejs/node/pull/54259#issuecomment-2308256647
if (process.features.inspector) {
expect('--heap-prof', 'B\n');
}

// V8 options
expect('--abort_on-uncaught_exception', 'B\n');
expect('--disallow-code-generation-from-strings', 'B\n');
Expand Down

0 comments on commit 0a28ac5

Please sign in to comment.