C# Class Microsoft.Isam.Esent.Interop.MemoryCache

Cache allocated chunks of memory that are needed for very short periods of time. The memory is not zeroed on allocation.
Mostra file Open project: ayende/managed-esent Class Usage Examples

Public Methods

Method Description
Allocate ( ) : byte[]

Allocates a chunk of memory. If memory is cached it is returned. If no memory is cached then it is allocated. Check the size of the returned buffer to determine how much memory was allocated.

Free ( byte data ) : void

Frees an unused buffer. This may be added to the cache.

MemoryCache ( int bufferSize, int maxCachedBuffers ) : System

Initializes a new instance of the MemoryCache class.

Private Methods

Method Description
GetStartingOffset ( ) : int

Get the offset in the cached buffers array to start allocating or freeing buffers to. This is done so that all threads don't start operating on slot zero, which would increase contention.

Method Details

Allocate() public method

Allocates a chunk of memory. If memory is cached it is returned. If no memory is cached then it is allocated. Check the size of the returned buffer to determine how much memory was allocated.
public Allocate ( ) : byte[]
return byte[]

Free() public method

Frees an unused buffer. This may be added to the cache.
public Free ( byte data ) : void
data byte The memory to free.
return void

MemoryCache() public method

Initializes a new instance of the MemoryCache class.
public MemoryCache ( int bufferSize, int maxCachedBuffers ) : System
bufferSize int /// The size of the buffers to cache. ///
maxCachedBuffers int /// The maximum number of buffers to cache. ///
return System