Browse Source

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

This increases HeapBlock utilization significantly (and reduces overall
memory usage.)
Andreas Kling 5 years ago
parent
commit
6c3afca686
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Libraries/LibJS/Heap/Heap.cpp

+ 2 - 1
Libraries/LibJS/Heap/Heap.cpp

@@ -60,7 +60,8 @@ Cell* Heap::allocate_cell(size_t size)
             return cell;
             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();
     auto* cell = block->allocate();
     m_blocks.append(move(block));
     m_blocks.append(move(block));
     return cell;
     return cell;