summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Heap/Heap.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-16 19:18:46 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-16 19:18:46 +0100
commitcb2e7d1c5f702cd80171ace1b201f382aa69f9d5 (patch)
treefcc493db644c2c045667087ec5816de84fb44626 /Libraries/LibJS/Heap/Heap.cpp
parentab404a2f8861a30ccc8e200ca06399b23add453c (diff)
downloadserenity-cb2e7d1c5f702cd80171ace1b201f382aa69f9d5.zip
LibJS+js: Add a debug option (js -g) to GC after every allocation
This is very useful for discovering collector bugs.
Diffstat (limited to 'Libraries/LibJS/Heap/Heap.cpp')
-rw-r--r--Libraries/LibJS/Heap/Heap.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Libraries/LibJS/Heap/Heap.cpp b/Libraries/LibJS/Heap/Heap.cpp
index 31707a1150..f8ee6794c7 100644
--- a/Libraries/LibJS/Heap/Heap.cpp
+++ b/Libraries/LibJS/Heap/Heap.cpp
@@ -49,6 +49,9 @@ Heap::~Heap()
Cell* Heap::allocate_cell(size_t size)
{
+ if (should_collect_on_every_allocation())
+ collect_garbage();
+
for (auto& block : m_blocks) {
if (size > block->cell_size())
continue;