Skip to content

Commit 8c2ac2e

Browse files
addaleaxBethGriggs
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 25fba2e commit 8c2ac2e

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
@@ -537,6 +537,14 @@ added: v6.0.0
537537

538538
Silence all process warnings (including deprecations).
539539

540+
### `--node-memory-debug`
541+
<!-- YAML
542+
added: REPLACEME
543+
-->
544+
545+
Enable extra debug checks for memory leaks in Node.js internals. This is
546+
usually only useful for developers debugging Node.js itself.
547+
540548
### `--openssl-config=file`
541549
<!-- YAML
542550
added: v6.9.0
@@ -1278,6 +1286,7 @@ Node.js options that are allowed are:
12781286
* `--no-deprecation`
12791287
* `--no-force-async-hooks-checks`
12801288
* `--no-warnings`
1289+
* `--node-memory-debug`
12811290
* `--openssl-config`
12821291
* `--pending-deprecation`
12831292
* `--policy-integrity`

doc/node.1

+4
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ These will still be enabled dynamically when `async_hooks` is enabled.
281281
.It Fl -no-warnings
282282
Silence all process warnings (including deprecations).
283283
.
284+
.It Fl -node-memory-debug
285+
Enable extra debug checks for memory leaks in Node.js internals. This is
286+
usually only useful for developers debugging Node.js itself.
287+
.
284288
.It Fl -openssl-config Ns = Ns Ar file
285289
Load an OpenSSL configuration file on startup.
286290
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
@@ -770,6 +770,12 @@ PerProcessOptionsParser::PerProcessOptionsParser(
770770
kAllowedInEnvironment);
771771

772772
Insert(iop, &PerProcessOptions::get_per_isolate_options);
773+
774+
AddOption("--node-memory-debug",
775+
"Run with extra debug checks for memory leaks in Node.js itself",
776+
NoOp{}, kAllowedInEnvironment);
777+
Implies("--node-memory-debug", "--debug-arraybuffer-allocations");
778+
Implies("--node-memory-debug", "--verify-base-objects");
773779
}
774780

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

0 commit comments

Comments
 (0)