LibJS: Round cell sizes up to a multiple of 16 bytes

This increases HeapBlock utilization significantly (and reduces overall
memory usage.)
This commit is contained in:
Andreas Kling 2020-03-21 11:49:18 +01:00
parent 2106dafd62
commit 6c3afca686
Notes: sideshowbarker 2024-07-19 08:12:25 +09:00

View file

@ -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;