Interface IPooledBufferService
Service interface for managing pooled byte buffers using ArrayPool for efficient memory usage.
public interface IPooledBufferService
- Extension Methods
Properties
LargestBufferRequested
Gets the largest buffer size requested.
int LargestBufferRequested { get; }
Property Value
RentedBuffers
Gets the current number of buffers rented from the pool.
int RentedBuffers { get; }
Property Value
Methods
GetStatistics()
Gets buffer usage statistics.
BufferPoolStatistics GetStatistics()
Returns
- BufferPoolStatistics
Buffer usage statistics.
RentBuffer(int, bool)
Rents a buffer of at least the specified minimum length.
IDisposablePooledBuffer RentBuffer(int minimumLength, bool clearBuffer = false)
Parameters
minimumLengthintThe minimum length of the array needed.
clearBufferboolWhether to clear the buffer contents before returning.
Returns
- IDisposablePooledBuffer
A disposable pooled buffer that returns to the pool on disposal.
Remarks
The returned buffer implements IDisposablePooledBuffer and must be
disposed to return the underlying memory to the pool. Using a using statement
or using declaration is recommended.
ReturnBuffer(IPooledBuffer, bool)
Returns a rented buffer to the pool.
void ReturnBuffer(IPooledBuffer buffer, bool clearBuffer = true)
Parameters
bufferIPooledBufferThe buffer to return.
clearBufferboolWhether to clear the buffer contents before returning to pool.