แก้ไข

แชร์ผ่าน


ArrayPool<T>.Return(T[], Boolean) Method

Definition

Returns an array to the pool that was previously obtained using the Rent(Int32) method on the same ArrayPool<T> instance.

public abstract void Return (T[] array, bool clearArray = false);
abstract member Return : 'T[] * bool -> unit
Public MustOverride Sub Return (array As T(), Optional clearArray As Boolean = false)

Parameters

array
T[]

A buffer to return to the pool that was previously obtained using the Rent(Int32) method.

clearArray
Boolean

Indicates whether the contents of the buffer should be cleared before reuse. If clearArray is set to true, and if the pool will store the buffer to enable subsequent reuse, the Return(T[], Boolean) method will clear the array of its contents so that a subsequent caller using the Rent(Int32) method will not see the content of the previous caller. If clearArray is set to false or if the pool will release the buffer, the array's contents are left unchanged.

Remarks

Once a buffer has been returned to the pool, the caller gives up all ownership of the buffer and must not use it. The reference returned from a given call to the Rent method must only be returned using the Return method once. The default ArrayPool<T> may hold onto the returned buffer in order to rent it again, or it may release the returned buffer if it's determined that the pool already has enough buffers stored.

Applies to