Skip to content

Commit 48158fb

Browse files
codebytereaduh95
authored andcommitted
src: stop leaking a CppHeap in CommonEnvironmentSetup
`CommonEnvironmentSetup` created a `CppHeap` for its `CreateParams` before deciding how to create the isolate, but `NewIsolate()` ignores `params->cpp_heap` and attaches a heap of its own (or the one from `IsolateSettings`). The first heap was never attached or destroyed, so every non-snapshotting setup leaked one `CppHeap`; cppgc's heap registry keeps it reachable, which is why LSAN stays quiet about it. Only create the heap on the snapshotting path, where the params go to the `SnapshotCreator` directly. Refs: #55337 Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com> PR-URL: #65792 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
1 parent 75a9fa6 commit 48158fb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/api/embed_helpers.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ CommonEnvironmentSetup::CommonEnvironmentSetup(
117117
Isolate::CreateParams params;
118118
params.array_buffer_allocator = impl_->allocator.get();
119119
params.external_references = external_references.data();
120-
params.cpp_heap =
121-
v8::CppHeap::Create(platform, v8::CppHeapCreateParams{{}}).release();
122120

123121
Isolate* isolate;
124122

@@ -130,6 +128,8 @@ CommonEnvironmentSetup::CommonEnvironmentSetup(
130128
// isolate, so that the memory reducer can be initialized.
131129
isolate = impl_->isolate = Isolate::Allocate(GetOrCreateIsolateGroup());
132130
platform->RegisterIsolate(isolate, loop);
131+
params.cpp_heap =
132+
v8::CppHeap::Create(platform, v8::CppHeapCreateParams{{}}).release();
133133

134134
impl_->snapshot_creator.emplace(isolate, params);
135135
isolate->SetCaptureStackTraceForUncaughtExceptions(

0 commit comments

Comments
 (0)