diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs index 4f84cff2e..2be91651e 100644 --- a/Source/Engine/Engine/NativeInterop.cs +++ b/Source/Engine/Engine/NativeInterop.cs @@ -437,7 +437,7 @@ namespace FlaxEngine private static Dictionary weakPool = weakPool1; private static Dictionary weakPoolOther = weakPool2; - private static int nextCollection = GC.CollectionCount(0) + 2; + private static int nextCollection = GC.CollectionCount(0) + 1; /// /// Tries to free all references to old weak handles so GC can collect them. @@ -449,15 +449,13 @@ namespace FlaxEngine lock (poolLock) { - // During initialization we might want to skip - // few generations between collections due to high GC pressure. - nextCollection = GC.CollectionCount(0) + 2; + nextCollection = GC.CollectionCount(0) + 1; var swap = weakPoolOther; weakPoolOther = weakPool; weakPool = swap; - weakPoolOther.Clear(); + weakPool.Clear(); } }