summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-25 18:28:39 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-26 01:04:51 +0200
commitd32f7112dc8e3aef664d8632b08aa6f47180f0d1 (patch)
treecc7db6eb9198ad9c2da5e3fa0a8c6a30c3d47dcf /Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
parenta3b2b20782c2961e06a0f86f06f2955c00282612 (diff)
downloadserenity-d32f7112dc8e3aef664d8632b08aa6f47180f0d1.zip
LibWeb: Intentionally leak the main thread JS VM
This way we avoid doing an expensive full GC on exit.
Diffstat (limited to 'Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
index 73c94e6a74..a78434db19 100644
--- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
@@ -51,6 +51,11 @@ JS::VM& main_thread_vm()
static RefPtr<JS::VM> vm;
if (!vm) {
vm = JS::VM::create(make<WebEngineCustomData>());
+
+ // NOTE: We intentionally leak the main thread JavaScript VM.
+ // This avoids doing an exhaustive garbage collection on process exit.
+ vm->ref();
+
static_cast<WebEngineCustomData*>(vm->custom_data())->event_loop.set_vm(*vm);
// FIXME: Implement 8.1.5.1 HostEnsureCanCompileStrings(callerRealm, calleeRealm), https://html.spec.whatwg.org/multipage/webappapis.html#hostensurecancompilestrings(callerrealm,-calleerealm)