From d32f7112dc8e3aef664d8632b08aa6f47180f0d1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Aug 2022 18:28:39 +0200 Subject: LibWeb: Intentionally leak the main thread JS VM This way we avoid doing an expensive full GC on exit. --- Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Userland/Libraries/LibWeb/Bindings') 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 vm; if (!vm) { vm = JS::VM::create(make()); + + // NOTE: We intentionally leak the main thread JavaScript VM. + // This avoids doing an exhaustive garbage collection on process exit. + vm->ref(); + static_cast(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) -- cgit v1.2.3