
public class OByteBufferPool extends Object implements OByteBufferPoolMXBean
DirectByteBuffer objects and pool for
DirectByteBuffer objects which were used and now are free to be reused by other parts of the code.
All DirectByteBuffer objects have the same size which is specified in objects constructor as "page size". Despite of
the fact that size of page is relatively small memory may be acquired from OS in relatively big chunks. It is done to optimize
memory usage inside of database.
OGlobalConfiguration.MEMORY_CHUNK_SIZE| Modifier and Type | Field and Description |
|---|---|
static String |
MBEAN_NAME
OByteBufferPool's MBean name. |
| Constructor and Description |
|---|
OByteBufferPool(int pageSize) |
OByteBufferPool(int pageSize,
int maxChunkSize) |
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
acquireDirect(boolean clear)
Acquires direct memory buffer.
|
long |
getAllocatedBufferCount() |
long |
getAllocatedMemory() |
double |
getAllocatedMemoryInGB() |
long |
getAllocatedMemoryInMB() |
int |
getBuffersInThePool() |
int |
getBufferSize() |
int |
getMaxPagesPerChunk() |
long |
getOverflowBufferCount() |
int |
getSize() |
static OByteBufferPool |
instance()
Pool returned by this method is used in all components of storage.
|
void |
registerMBean()
Registers the MBean for this byte buffer pool.
|
void |
release(ByteBuffer buffer)
Put buffer which is not used any more back to the pool.
|
void |
unregisterMBean()
Unregisters the MBean for this byte buffer pool.
|
public static final String MBEAN_NAME
OByteBufferPool's MBean name.public OByteBufferPool(int pageSize)
pageSize - Size of single page (instance of DirectByteBuffer) returned by pool.public OByteBufferPool(int pageSize,
int maxChunkSize)
pageSize - Size of single page (DirectByteBuffer) returned by pool.maxChunkSize - public static OByteBufferPool instance()
OGlobalConfiguration.MEMORY_CHUNK_SIZE Amount of maximum memory preallocated by this pool equals to sum
of OGlobalConfiguration.DISK_CACHE_SIZE and OGlobalConfiguration.WAL_CACHE_SIZE and one.
Size of single page equals to OGlobalConfiguration.DISK_CACHE_PAGE_SIZE.
public int getSize()
public int getMaxPagesPerChunk()
public ByteBuffer acquireDirect(boolean clear)
If we reached maximum amount of preallocated memory chunks then small portion of direct memory equals to page size is allocated. Byte order of returned direct memory buffer equals to native byte order.
Position of returned buffer is always zero.
clear - Whether returned buffer should be filled with zeros before return.public void release(ByteBuffer buffer)
buffer - Not used instance of buffer.public int getBufferSize()
getBufferSize in interface OByteBufferPoolMXBeanOByteBufferPool.public long getAllocatedBufferCount()
getAllocatedBufferCount in interface OByteBufferPoolMXBeanOByteBufferPool,
this does not include the overflow buffers.public long getOverflowBufferCount()
getOverflowBufferCount in interface OByteBufferPoolMXBeanOByteBufferPool.public int getBuffersInThePool()
getBuffersInThePool in interface OByteBufferPoolMXBeanOByteBufferPool.public long getAllocatedMemory()
getAllocatedMemory in interface OByteBufferPoolMXBeanOByteBufferPool,
including the overflow buffer allocations.public long getAllocatedMemoryInMB()
getAllocatedMemoryInMB in interface OByteBufferPoolMXBeanOByteBufferPool,
including the overflow buffer allocations.public double getAllocatedMemoryInGB()
getAllocatedMemoryInGB in interface OByteBufferPoolMXBeanOByteBufferPool,
including the overflow buffer allocations.public void registerMBean()
OByteBufferPoolMXBeanpublic void unregisterMBean()
OByteBufferPoolMXBeanCopyright © 2009–2016 Orient Technologies. All rights reserved.