Despawn function has a very slow performance. It takes 10 seconds to despawn 50k objects.
This is due to the following line
Assert.That(!_inactiveItems.Contains(item),
"Tried to return an item to pool {0} twice", GetType());
The security should either be optional or refactored to provide a faster duplicate detection.
According to Microsoft Dispose pattern (https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose), Disposable object should implement a boolean to avoid items being disposed twice. So I would argue that the security is unnecessary. However the memory pool documentation should be amended to include the proper dispose pattern.
Despawn function has a very slow performance. It takes 10 seconds to despawn 50k objects. This is due to the following line
The security should either be optional or refactored to provide a faster duplicate detection.
According to Microsoft Dispose pattern (https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose), Disposable object should implement a boolean to avoid items being disposed twice. So I would argue that the security is unnecessary. However the memory pool documentation should be amended to include the proper dispose pattern.