From 6c3afca6866023b12c5f9d220cbedccd002bfd60 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 21 Mar 2020 11:49:18 +0100 Subject: [PATCH] LibJS: Round cell sizes up to a multiple of 16 bytes This increases HeapBlock utilization significantly (and reduces overall memory usage.) --- Libraries/LibJS/Heap/Heap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/LibJS/Heap/Heap.cpp b/Libraries/LibJS/Heap/Heap.cpp index beb7403284..b289116647 100644 --- a/Libraries/LibJS/Heap/Heap.cpp +++ b/Libraries/LibJS/Heap/Heap.cpp @@ -60,7 +60,8 @@ Cell* Heap::allocate_cell(size_t size) return cell; } - auto block = HeapBlock::create_with_cell_size(*this, size); + size_t cell_size = round_up_to_power_of_two(size, 16); + auto block = HeapBlock::create_with_cell_size(*this, cell_size); auto* cell = block->allocate(); m_blocks.append(move(block)); return cell;