diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2020-10-21 22:41:11 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2020-10-21 22:41:11 +0300 |
commit | d2a3078460095bef0db0772eb94a0b5d3232ec84 (patch) | |
tree | 5b0a050d43b355cc18fad698fecac0c0c809a8a9 /src/node.cc | |
parent | d5088d8dbbcf1cdc32e15a37e132a43e95dece2f (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.cc')
-rw-r--r-- | src/node.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc index 521cae7757d..efb4876002f 100644 --- a/src/node.cc +++ b/src/node.cc @@ -275,6 +275,10 @@ static void AtomicsWaitCallback(Isolate::AtomicsWaitEvent event, void Environment::InitializeDiagnostics() { isolate_->GetHeapProfiler()->AddBuildEmbedderGraphCallback( Environment::BuildEmbedderGraph, this); + if (options_->heap_snapshot_near_heap_limit > 0) { + isolate_->AddNearHeapLimitCallback(Environment::NearHeapLimitCallback, + this); + } if (options_->trace_uncaught) isolate_->SetCaptureStackTraceForUncaughtExceptions(true); if (options_->trace_atomics_wait) { |