Skip to content

Commit

Permalink
opt: avoid memory peak on chunk rent
Browse files Browse the repository at this point in the history
  • Loading branch information
labbbirder committed May 24, 2024
1 parent 4447a73 commit 4e6e2c5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Arch/Core/Archetype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,11 @@ public int CalculateEntitiesPerChunk(ComponentType[] types)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void EnsureChunkCapacity(int newCapacity)
{
if (ChunkCapacity >= newCapacity)
{
return;
}

// Increase chunk array size
var newChunks = ArrayPool<Chunk>.Shared.Rent(newCapacity);
Array.Copy(Chunks, newChunks, ChunkCapacity);
Expand Down

0 comments on commit 4e6e2c5

Please sign in to comment.