fix: support for v8.setHeapSnapshotNearHeapLimit api (#45632)
* fix: support for v8.setHeapSnapshotNearHeapLimit api Co-authored-by: deepak1556 <hop2deep@gmail.com> * docs: add support Co-authored-by: deepak1556 <hop2deep@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: deepak1556 <hop2deep@gmail.com>
This commit is contained in:
parent
cf85d2d7c1
commit
fa0da6f19f
10 changed files with 66 additions and 6 deletions
|
@ -237,7 +237,8 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {
|
|||
node_bindings_->Initialize(js_env_->isolate()->GetCurrentContext());
|
||||
// Create the global environment.
|
||||
node_env_ = node_bindings_->CreateEnvironment(
|
||||
js_env_->isolate()->GetCurrentContext(), js_env_->platform());
|
||||
js_env_->isolate()->GetCurrentContext(), js_env_->platform(),
|
||||
js_env_->max_young_generation_size_in_bytes());
|
||||
|
||||
node_env_->set_trace_sync_io(node_env_->options()->trace_sync_io);
|
||||
|
||||
|
|
|
@ -33,9 +33,15 @@ namespace electron {
|
|||
|
||||
namespace {
|
||||
|
||||
gin::IsolateHolder CreateIsolateHolder(v8::Isolate* isolate) {
|
||||
gin::IsolateHolder CreateIsolateHolder(v8::Isolate* isolate,
|
||||
size_t* max_young_generation_size) {
|
||||
std::unique_ptr<v8::Isolate::CreateParams> create_params =
|
||||
gin::IsolateHolder::getDefaultIsolateParams();
|
||||
// The value is needed to adjust heap limit when capturing
|
||||
// snapshot via v8.setHeapSnapshotNearHeapLimit(limit) or
|
||||
// --heapsnapshot-near-heap-limit=max_count.
|
||||
*max_young_generation_size =
|
||||
create_params->constraints.max_young_generation_size_in_bytes();
|
||||
// Align behavior with V8 Isolate default for Node.js.
|
||||
// This is necessary for important aspects of Node.js
|
||||
// including heap and cpu profilers to function properly.
|
||||
|
@ -55,7 +61,8 @@ gin::IsolateHolder CreateIsolateHolder(v8::Isolate* isolate) {
|
|||
JavascriptEnvironment::JavascriptEnvironment(uv_loop_t* event_loop,
|
||||
bool setup_wasm_streaming)
|
||||
: isolate_holder_{CreateIsolateHolder(
|
||||
Initialize(event_loop, setup_wasm_streaming))},
|
||||
Initialize(event_loop, setup_wasm_streaming),
|
||||
&max_young_generation_size_)},
|
||||
isolate_{isolate_holder_.isolate()},
|
||||
locker_{isolate_} {
|
||||
isolate_->Enter();
|
||||
|
|
|
@ -36,6 +36,9 @@ class JavascriptEnvironment {
|
|||
|
||||
node::MultiIsolatePlatform* platform() const { return platform_.get(); }
|
||||
v8::Isolate* isolate() const { return isolate_; }
|
||||
size_t max_young_generation_size_in_bytes() const {
|
||||
return max_young_generation_size_;
|
||||
}
|
||||
|
||||
static v8::Isolate* GetIsolate();
|
||||
|
||||
|
@ -43,6 +46,7 @@ class JavascriptEnvironment {
|
|||
v8::Isolate* Initialize(uv_loop_t* event_loop, bool setup_wasm_streaming);
|
||||
std::unique_ptr<node::MultiIsolatePlatform> platform_;
|
||||
|
||||
size_t max_young_generation_size_ = 0;
|
||||
gin::IsolateHolder isolate_holder_;
|
||||
|
||||
// owned-by: isolate_holder_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue