From 223be8131d5e9863fadaa937ef917ef2f51f42f1 Mon Sep 17 00:00:00 2001 From: Lars Date: Sun, 29 Jan 2023 21:47:08 +0100 Subject: [PATCH] Fixed memory leak during `.Add` and `.Remove`. --- src/Arch.Samples/Systems.cs | 3 +++ src/Arch/Arch.csproj | 3 ++- src/Arch/Core/Utils/CompileTimeStatics.cs | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Arch.Samples/Systems.cs b/src/Arch.Samples/Systems.cs index 9204cb4e..bd7963bb 100644 --- a/src/Arch.Samples/Systems.cs +++ b/src/Arch.Samples/Systems.cs @@ -196,6 +196,9 @@ public override void Update(in GameTime time) sprite.Color.G += (byte)(_gameTime.ElapsedGameTime.TotalMilliseconds * 0.08); sprite.Color.B += (byte)(_gameTime.ElapsedGameTime.TotalMilliseconds * 0.08); }); + + World.Add(in _entitiesToChangeColor); + World.Remove(in _entitiesToChangeColor); } } diff --git a/src/Arch/Arch.csproj b/src/Arch/Arch.csproj index 1bac3875..eee03b02 100644 --- a/src/Arch/Arch.csproj +++ b/src/Arch/Arch.csproj @@ -14,13 +14,14 @@ Arch Arch - 1.1.7 + 1.1.8 genaray Apache-2.0 A high performance c# net.6 and net.7 archetype based ECS ( Entity component system ). Fixed structural changes memory leak. Added destroy, set, add and remove operations for QueryDescriptions to target a range of entities. + Fixed proper entityinfo update. Small performance improvements. c#;.net;.net6;.net7;ecs;game;entity;gamedev; game-development; game-engine; entity-component-system; diff --git a/src/Arch/Core/Utils/CompileTimeStatics.cs b/src/Arch/Core/Utils/CompileTimeStatics.cs index aa784245..f85ac356 100644 --- a/src/Arch/Core/Utils/CompileTimeStatics.cs +++ b/src/Arch/Core/Utils/CompileTimeStatics.cs @@ -351,6 +351,7 @@ public static int GetHashCode(ref SpanBitSet obj) { if ((value & 1) != 1) { + value >>= 1; continue; }