Class OByteBufferPool
java.lang.Object
com.orientechnologies.common.directmemory.OByteBufferPool
- All Implemented Interfaces:
OByteBufferPoolMXBean
Object of this class works at the same time as factory for
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".- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOByteBufferPool(int pageSize) OByteBufferPool(int pageSize, ODirectMemoryAllocator allocator, int poolSize) -
Method Summary
Modifier and TypeMethodDescriptionfinal OPointeracquireDirect(boolean clear, MemTrace intention) Acquires direct memory buffer with native byte order.voidChecks whether there are not released buffers in the poolvoidclear()Clears pool and dealocates memory.final intstatic OByteBufferPoolinstance(OContextConfiguration contextConfiguration) final voidPut buffer which is not used any more back to the pool or frees direct memory if pool is full.
-
Constructor Details
-
OByteBufferPool
public OByteBufferPool(int pageSize) - Parameters:
pageSize- Size of single page (instance ofDirectByteBuffer) returned by pool.
-
OByteBufferPool
- Parameters:
allocator- Direct memory allocator to use.pageSize- Size of single page (instance ofDirectByteBuffer) returned by pool.poolSize- Size of the page pool
-
-
Method Details
-
instance
- Returns:
- Singleton instance
-
acquireDirect
Acquires direct memory buffer with native byte order. If there is free (already released) direct memory page we reuse it, otherwise new memory chunk is allocated from direct memory.- Parameters:
clear- Whether returned buffer should be filled with zeros before return.intention- Why this memory is allocated. This parameter is used for memory profiling.- Returns:
- Direct memory buffer instance.
-
release
Put buffer which is not used any more back to the pool or frees direct memory if pool is full.- Parameters:
pointer- Not used instance of buffer.- See Also:
-
getPoolSize
public final int getPoolSize()- Specified by:
getPoolSizein interfaceOByteBufferPoolMXBean- Returns:
- Current size of the memory pool
-
checkMemoryLeaks
public void checkMemoryLeaks()Checks whether there are not released buffers in the pool -
clear
public void clear()Clears pool and dealocates memory.
-