Class ArrayPool

Public

Lightweight Array Pool.

Handy class for pooling arrays of type T.

Usage:

  • Claim a new array usingSomeClass[] foo = ArrayPool<SomeClass>.Claim (capacity);

  • Use it and do stuff with it

  • Release it withArrayPool<SomeClass>.Release (foo);

Warning

Arrays returned from the Claim method may contain arbitrary data. You cannot rely on it being zeroed out.

After you have released a array, you should never use it again, if you do use it your code may modify it at the same time as some other code is using it which will likely lead to bad results.

Since

Version 3.8.6

Public Static Methods

Claim (minimumLength)

Returns an array with at least the specified length.

Public Static
ClaimWithExactLength (length)

Returns an array with the specified length.

Public Static
Release (array, allowNonPowerOfTwo=…)

Pool an array.

Public Static

Private/Protected Members

exactPool
Private Static Readonly
MaximumExactArrayLength

Maximum length of an array pooled using ClaimWithExactLength.

Private
pool

Internal pool.

Private Static Readonly