Skip to content

Commit 1d5fa88

Browse files
addaleaxTrott
authored andcommitted
cli: add --node-memory-debug option
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>
1 parent 936ce85 commit 1d5fa88

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

doc/api/cli.md

+9
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,14 @@ added: v6.0.0
546546

547547
Silence all process warnings (including deprecations).
548548

549+
### `--node-memory-debug`
550+
<!-- YAML
551+
added: REPLACEME
552+
-->
553+
554+
Enable extra debug checks for memory leaks in Node.js internals. This is
555+
usually only useful for developers debugging Node.js itself.
556+
549557
### `--openssl-config=file`
550558
<!-- YAML
551559
added: v6.9.0
@@ -1282,6 +1290,7 @@ Node.js options that are allowed are:
12821290
* `--no-deprecation`
12831291
* `--no-force-async-hooks-checks`
12841292
* `--no-warnings`
1293+
* `--node-memory-debug`
12851294
* `--openssl-config`
12861295
* `--pending-deprecation`
12871296
* `--policy-integrity`

doc/node.1

+4
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ These will still be enabled dynamically when `async_hooks` is enabled.
278278
.It Fl -no-warnings
279279
Silence all process warnings (including deprecations).
280280
.
281+
.It Fl -node-memory-debug
282+
Enable extra debug checks for memory leaks in Node.js internals. This is
283+
usually only useful for developers debugging Node.js itself.
284+
.
281285
.It Fl -openssl-config Ns = Ns Ar file
282286
Load an OpenSSL configuration file on startup.
283287
Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is built with

src/node_options.cc

+6
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,12 @@ PerProcessOptionsParser::PerProcessOptionsParser(
762762
kAllowedInEnvironment);
763763

764764
Insert(iop, &PerProcessOptions::get_per_isolate_options);
765+
766+
AddOption("--node-memory-debug",
767+
"Run with extra debug checks for memory leaks in Node.js itself",
768+
NoOp{}, kAllowedInEnvironment);
769+
Implies("--node-memory-debug", "--debug-arraybuffer-allocations");
770+
Implies("--node-memory-debug", "--verify-base-objects");
765771
}
766772

767773
inline std::string RemoveBrackets(const std::string& host) {

0 commit comments

Comments
 (0)