Skip to content

Commit

Permalink
cli: add --node-memory-debug option
Browse files Browse the repository at this point in the history
Add a public switch that turns on features for debugging memory
leaks inside of Node.js core.

PR-URL: #35537
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
addaleax authored and MylesBorins committed Aug 31, 2021
1 parent 8b9215d commit 39eba0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,14 @@ added: v6.0.0

Silence all process warnings (including deprecations).

### `--node-memory-debug`
<!-- YAML
added: REPLACEME
-->

Enable extra debug checks for memory leaks in Node.js internals. This is
usually only useful for developers debugging Node.js itself.

### `--openssl-config=file`
<!-- YAML
added: v6.9.0
Expand Down Expand Up @@ -1278,6 +1286,7 @@ Node.js options that are allowed are:
* `--no-deprecation`
* `--no-force-async-hooks-checks`
* `--no-warnings`
* `--node-memory-debug`
* `--openssl-config`
* `--pending-deprecation`
* `--policy-integrity`
Expand Down
4 changes: 4 additions & 0 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ These will still be enabled dynamically when `async_hooks` is enabled.
.It Fl -no-warnings
Silence all process warnings (including deprecations).
.
.It Fl -node-memory-debug
Enable extra debug checks for memory leaks in Node.js internals. This is
usually only useful for developers debugging Node.js itself.
.
.It Fl -openssl-config Ns = Ns Ar file
Load an OpenSSL configuration file on startup.
Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is built with
Expand Down
6 changes: 6 additions & 0 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,12 @@ PerProcessOptionsParser::PerProcessOptionsParser(
kAllowedInEnvironment);

Insert(iop, &PerProcessOptions::get_per_isolate_options);

AddOption("--node-memory-debug",
"Run with extra debug checks for memory leaks in Node.js itself",
NoOp{}, kAllowedInEnvironment);
Implies("--node-memory-debug", "--debug-arraybuffer-allocations");
Implies("--node-memory-debug", "--verify-base-objects");
}

inline std::string RemoveBrackets(const std::string& host) {
Expand Down

0 comments on commit 39eba0a

Please sign in to comment.