1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

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

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;