Table of Contents

Class VersatileBufferAllocator

Namespace
VAST.Common
Assembly
VAST.Common.dll

Provides an abstract base class for pre-allocating and managing memory buffers.

public abstract class VersatileBufferAllocator : IDisposable
Inheritance
VersatileBufferAllocator
Implements
Inherited Members

Remarks

Buffer allocators pre-allocate a pool of memory buffers that are reused throughout the application's lifetime. This approach reduces allocation/deallocation overhead and prevents memory fragmentation.

Properties

BufferCount

Gets the current number of pre-allocated buffers.

public virtual int BufferCount { get; }

Property Value

int

BufferSize

Gets the size of a single buffer in bytes.

public virtual int BufferSize { get; }

Property Value

int

FreeBufferCount

Gets the current number of free (available) buffers.

public virtual int FreeBufferCount { get; }

Property Value

int

Remarks

This property is thread-safe but its value is informational only, as it may change while you are processing it.

MaxGrowth

Gets the maximum growth factor for the number of buffers.

public virtual float MaxGrowth { get; }

Property Value

float

OriginalBufferCount

Gets the number of buffers that were originally pre-allocated during allocator initialization.

public virtual int OriginalBufferCount { get; }

Property Value

int

Parameters

Gets the parameters used to initialize this allocator.

public virtual VersatileBufferAllocatorParameters Parameters { get; protected set; }

Property Value

VersatileBufferAllocatorParameters

Methods

Dispose()

Releases all resources used by this allocator.

public abstract void Dispose()

LockBuffer()

Acquires a free buffer from the pool, locks it, and returns it to the caller.

public abstract VersatileBuffer LockBuffer()

Returns

VersatileBuffer

A locked buffer ready for use.

Reallocate(int, int)

Re-allocates the buffer pool with the specified parameters.

public abstract void Reallocate(int bufferSize, int bufferCount)

Parameters

bufferSize int

The new size for each buffer in bytes.

bufferCount int

The new number of buffers to allocate.