
public class OByteBufferPool extends Object implements OOrientShutdownListener, 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,
long preAllocationLimit) |
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
acquireDirect(boolean clear)
Acquires direct memory buffer.
|
long |
getAllocatedMemory() |
double |
getAllocatedMemoryInGB() |
long |
getAllocatedMemoryInMB() |
int |
getBuffersInThePool() |
int |
getBufferSize() |
int |
getMaxPagesPerChunk() |
int |
getMaxPagesPerSingleArea() |
long |
getOverflowBufferCount() |
int |
getPoolSize() |
long |
getPreAllocatedBufferCount() |
long |
getPreAllocationLimit() |
int |
getSize() |
static OByteBufferPool |
instance()
Pool returned by this method is used in all components of storage.
|
void |
logTrackedBufferInfo(String prefix,
ByteBuffer buffer)
Logs all known tracking information about the given buffer.
|
void |
onShutdown() |
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.
|
void |
verifyState()
Verifies the state of this byte buffer pool for a consistency, leaks, etc.
|
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,
long preAllocationLimit)
pageSize - Size of single page (DirectByteBuffer) returned by pool.maxChunkSize - Maximum allocation chunk sizepreAllocationLimit - Limit of memory which will be allocated by big chunkspublic 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 getPreAllocatedBufferCount()
getPreAllocatedBufferCount 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 long getPreAllocationLimit()
getPreAllocationLimit in interface OByteBufferPoolMXBeanpublic int getMaxPagesPerSingleArea()
getMaxPagesPerSingleArea in interface OByteBufferPoolMXBeanpublic int getPoolSize()
getPoolSize in interface OByteBufferPoolMXBeanpublic void registerMBean()
OByteBufferPoolMXBeanpublic void unregisterMBean()
OByteBufferPoolMXBeanpublic void verifyState()
OGlobalConfiguration.DIRECT_MEMORY_TRACK_MODE
must be on, otherwise this method does nothing. Detected problems will be printed to the error log. If assertions are on and
erroneous state is detected, verification will fail with AssertionError exception.public void logTrackedBufferInfo(String prefix, ByteBuffer buffer)
OGlobalConfiguration.DIRECT_MEMORY_TRACK_MODE must be on,
otherwise this method does nothing.prefix - the log message prefixbuffer - the buffer to print information aboutpublic void onShutdown()
onShutdown in interface OOrientShutdownListenerCopyright © 2009–2025 OrientDB. All rights reserved.