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_worker.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_worker.cc')
-rw-r--r-- | src/node_worker.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/node_worker.cc b/src/node_worker.cc index 2006380cd41..e28aab7fb24 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -159,6 +159,9 @@ class WorkerThreadData { Isolate::Initialize(isolate, params); SetIsolateUpForNode(isolate); + // Be sure it's called before Environment::InitializeDiagnostics() + // so that this callback stays when the callback of + // --heapsnapshot-near-heap-limit gets is popped. isolate->AddNearHeapLimitCallback(Worker::NearHeapLimit, w); { @@ -177,6 +180,8 @@ class WorkerThreadData { if (w_->per_isolate_opts_) isolate_data_->set_options(std::move(w_->per_isolate_opts_)); isolate_data_->set_worker_context(w_); + isolate_data_->max_young_gen_size = + params.constraints.max_young_generation_size_in_bytes(); } Mutex::ScopedLock lock(w_->mutex_); |