csharp
public static class PooledArrayRents scratch arrays from ArrayPool`1 with the engine's clearing policy applied, so callers never have to decide it.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The policy. An array of a type that contains references is cleared when returned; an array of unmanaged elements is not. The reason is not tidiness — a returned array keeps its contents alive, so an uncleared Entity[] in a pool roots every entity it last held until the array is rented again and overwritten. Unmanaged elements root nothing, so clearing them is pure cost, and it is the case that runs every frame.
Methods (3)
public static PooledArray<T> Rent<T>(int minimumLength)Rents an array of at least elements.
public static PooledArray<T> RentCleared<T>(int minimumLength)Rents an array of at least elements, zeroed.
public static bool ClearsOnReturn<T>()Whether returning a array clears it first.
Used by (1)
- PoolingTestsVixen.Core.Tests