Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2020-10-21 22:41:11 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2020-10-21 22:41:11 +0300
commitd2a3078460095bef0db0772eb94a0b5d3232ec84 (patch)
tree5b0a050d43b355cc18fad698fecac0c0c809a8a9 /src/node_options.cc
parentd5088d8dbbcf1cdc32e15a37e132a43e95dece2f (diff)
src: add --heapsnapshot-near-heap-limit option
This patch adds a --heapsnapshot-near-heap-limit CLI option that takes heap snapshots when the V8 heap is approaching the heap size limit. It will try to write the snapshots to disk before the program crashes due to OOM. PR-URL: https://github.com/nodejs/node/pull/33010 Refs: https://github.com/nodejs/node/issues/27552 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'src/node_options.cc')
-rw-r--r--src/node_options.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/node_options.cc b/src/node_options.cc
index 4fb4f455c47..04893fee408 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -118,6 +118,10 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
"used, not both");
}
+ if (heap_snapshot_near_heap_limit < 0) {
+ errors->push_back("--heap-snapshot-near-heap-limit must not be negative");
+ }
+
#if HAVE_INSPECTOR
if (!cpu_prof) {
if (!cpu_prof_name.empty()) {
@@ -341,6 +345,12 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"Generate heap snapshot on specified signal",
&EnvironmentOptions::heap_snapshot_signal,
kAllowedInEnvironment);
+ AddOption("--heapsnapshot-near-heap-limit",
+ "Generate heap snapshots whenever V8 is approaching "
+ "the heap limit. No more than the specified number of "
+ "heap snapshots will be generated.",
+ &EnvironmentOptions::heap_snapshot_near_heap_limit,
+ kAllowedInEnvironment);
AddOption("--http-parser", "", NoOp{}, kAllowedInEnvironment);
AddOption("--insecure-http-parser",
"use an insecure HTTP parser that accepts invalid HTTP headers",