public void GetAllocatorByIDTest() { ForwardAllocator allocator = new ForwardAllocator(Allocator.Default); Assert.IsTrue(Allocator.IsCached(allocator)); Assert.IsTrue(Allocator.IsCached(allocator.ID)); allocator.Dispose(); Assert.IsFalse(Allocator.IsCached(allocator)); Assert.IsFalse(Allocator.IsCached(allocator.ID)); }
public void AllocatorCacheLimitTest() { ForwardAllocator[] allocators = new ForwardAllocator[20]; for (int i = 0; i < allocators.Length; i++) { allocators[i] = new ForwardAllocator(Allocator.Default); } var allocator1 = new ForwardAllocator(Allocator.Default); Assert.IsFalse(Allocator.IsCached(allocator1)); Assert.IsFalse(Allocator.IsCached(allocator1.ID)); allocator1.Dispose(); for (int i = 0; i < allocators.Length; i++) { allocators[i].Dispose(); } var allocator2 = new ForwardAllocator(Allocator.Default); Assert.IsTrue(Allocator.IsCached(allocator2)); Assert.IsTrue(Allocator.IsCached(allocator2.ID)); }