Class MemoryBufferPool
Handle a pool of large memory buffers
Inheritance
Namespace: EPiServer.Core.Internal
Assembly: EPiServer.dll
Version: 12.0.3Syntax
public class MemoryBufferPool : Object
Remarks
The buffers will be at least 87040 bytes (>85000 so as to go into the large object heap)
Constructors
MemoryBufferPool()
Construct a pool with a default memory buffer size. It is thread safe.
Declaration
public MemoryBufferPool()
Remarks
The normal case is to have static field representing the pool so that many threads can share it.
MemoryBufferPool(Int32)
Construct a pool. It is thread safe.
Declaration
public MemoryBufferPool(int bufferSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | bufferSize | The size of each buffer. May be rounded upwards - always check the buffer Lenth property |
Remarks
The normal case is to have static field representing the pool so that many threads can share it.
Properties
Instance
Gets the singleton instance. It is thread-safe.
Declaration
public static MemoryBufferPool Instance { get; }
Property Value
Type | Description |
---|---|
MemoryBufferPool | The instance. |
Remarks
Whenever a MemoryBufferPool is required, it is recommended to use the singleton instance available here, as it allows for efficient sharing and re-use of buffers. Only if a pool requiring significantly different characterstics should a new pool be instantiated.
PerformanceCounters
Gets the collection of performance counters
Declaration
public MemoryBufferPool.Counters PerformanceCounters { get; }
Property Value
Type | Description |
---|---|
MemoryBufferPool.Counters |
Methods
Allocate()
Get a buffer. There is no guarantee of the size returned.
Declaration
public byte[] Allocate()
Returns
Type | Description |
---|---|
System.Byte[] | A buffer. Check the Length property to know how large it is. |
Release(Byte[])
Actively re-release a buffer. Do not use it afterwards - it may be re-used at any time.
Declaration
public void Release(byte[] theBuffer)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | theBuffer | A buffer that you want re-used. It does not need to allocated by this manager. |
Release(ArrayList)
Acitvely re-release an ArrayList of buffers. Do not use these afterwards. The ArrayList is cleared.
Declaration
public void Release(ArrayList theBuffers)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.ArrayList | theBuffers | An ArrayList of byte[]'s. Cleared after call |
Remarks
This method is to optimize for the case we have many buffers, since we'll do it all in one lock