WebContent: Try to run manual GC with less stuff on the stack

This makes it more likely to succeed in collecting stuff that's actually
dead, by reducing the memory range scanned for possible pointers.
This commit is contained in:
Andreas Kling 2024-11-10 15:14:12 +01:00 committed by Andreas Kling
parent 08ae305dc5
commit 1510c1876c
Notes: github-actions[bot] 2024-11-10 18:14:16 +00:00

View file

@ -11,6 +11,7 @@
#include <AK/JsonObject.h>
#include <AK/QuickSort.h>
#include <LibCore/EventLoop.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Font/FontDatabase.h>
#include <LibGfx/SystemTheme.h>
@ -354,7 +355,10 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString const& request,
}
if (request == "collect-garbage") {
Web::Bindings::main_thread_vm().heap().collect_garbage(JS::Heap::CollectionType::CollectGarbage, true);
// NOTE: We use deferred_invoke here to ensure that GC runs with as little on the stack as possible.
Core::deferred_invoke([] {
Web::Bindings::main_thread_vm().heap().collect_garbage(JS::Heap::CollectionType::CollectGarbage, true);
});
return;
}