diff --git a/Libraries/LibJS/Heap/Heap.cpp b/Libraries/LibJS/Heap/Heap.cpp index a4a131fe5c..1bfa91e54e 100644 --- a/Libraries/LibJS/Heap/Heap.cpp +++ b/Libraries/LibJS/Heap/Heap.cpp @@ -89,6 +89,9 @@ Cell* Heap::allocate_cell(size_t size) void Heap::collect_garbage(CollectionType collection_type, bool print_report) { + ASSERT(!m_collecting_garbage); + TemporaryChange change(m_collecting_garbage, true); + Core::ElapsedTimer collection_measurement_timer; collection_measurement_timer.start(); if (collection_type == CollectionType::CollectGarbage) { diff --git a/Libraries/LibJS/Heap/Heap.h b/Libraries/LibJS/Heap/Heap.h index b1381a8dae..0d727210a4 100644 --- a/Libraries/LibJS/Heap/Heap.h +++ b/Libraries/LibJS/Heap/Heap.h @@ -109,6 +109,8 @@ private: size_t m_gc_deferrals { 0 }; bool m_should_gc_when_deferral_ends { false }; + + bool m_collecting_garbage { false }; }; }