public class PoolingMemoryManager extends Object implements HazelcastMemoryManager, GarbageCollectable, com.hazelcast.internal.metrics.MetricsProvider
freed by the thread that allocated it.
registerThread(Thread), the thread-local manager
dedicated to that thread will be looked up (or created); otherwise the request will be forwarded to the
global manager.SIZE_INVALID| Constructor and Description |
|---|
PoolingMemoryManager(com.hazelcast.memory.MemorySize cap) |
PoolingMemoryManager(com.hazelcast.memory.MemorySize size,
int minBlockSize,
int pageSize) |
PoolingMemoryManager(com.hazelcast.memory.MemorySize size,
int minBlockSize,
int pageSize,
float metadataSpacePercentage) |
PoolingMemoryManager(com.hazelcast.memory.MemorySize cap,
int minBlockSize,
int pageSize,
float metadataSpacePercentage,
FreeMemoryChecker freeMemoryChecker) |
| Modifier and Type | Method and Description |
|---|---|
long |
allocate(long size)
Allocates memory from an internal memory pool or falls back to OS
if not enough memory available in pool.
|
void |
compact()
Compacts the memory region.
|
void |
deregisterThread(Thread thread) |
void |
dispose() |
void |
free(long address,
long size)
Gives allocated memory block back to internal pool or to OS
if pool is over capacity.
|
void |
gc() |
long |
getAllocatedSize(long address)
Returns allocated size of memory block as if it belongs to and is allocated by this memory manager.
|
com.hazelcast.memory.GlobalPoolingMemoryManager |
getGlobalMemoryManager() |
int |
getHeaderSize() |
HazelcastMemoryManager |
getMemoryManager() |
com.hazelcast.memory.MemoryStats |
getMemoryStats() |
com.hazelcast.internal.memory.MemoryAllocator |
getSystemAllocator() |
long |
getUsableSize(long address)
Returns size of memory block as if it belongs to and is allocated by this memory manager.
|
boolean |
isDisposed()
Gets the disposed state of this memory manager.
|
long |
newSequence()
Creates a new sequence.
|
protected ThreadLocalPoolingMemoryManager |
newThreadLocalPoolingMemoryManager(int minBlockSize,
int pageSize,
LibMalloc malloc,
PooledNativeMemoryStats stats) |
void |
provideMetrics(com.hazelcast.internal.metrics.MetricsRegistry registry) |
long |
reallocate(long address,
long currentSize,
long newSize) |
void |
registerThread(Thread thread) |
String |
toString() |
long |
validateAndGetAllocatedSize(long address)
Returns allocated size of memory block if and only if it belongs to and is allocated by this memory manager.
|
long |
validateAndGetUsableSize(long address)
Returns size of memory block if and only if it belongs to and is allocated by this memory manager.
|
public PoolingMemoryManager(com.hazelcast.memory.MemorySize cap)
public PoolingMemoryManager(com.hazelcast.memory.MemorySize size,
int minBlockSize,
int pageSize)
public PoolingMemoryManager(com.hazelcast.memory.MemorySize size,
int minBlockSize,
int pageSize,
float metadataSpacePercentage)
public PoolingMemoryManager(com.hazelcast.memory.MemorySize cap,
int minBlockSize,
int pageSize,
float metadataSpacePercentage,
FreeMemoryChecker freeMemoryChecker)
public long allocate(long size)
Complement of free(long, long).
Memory allocated by this method should be freed using
free(long, long)
allocate in interface com.hazelcast.internal.memory.MemoryAllocatorallocate in interface HazelcastMemoryManagersize - of requested memory blockNativeOutOfMemoryError - if not enough memory is availablepublic long reallocate(long address,
long currentSize,
long newSize)
reallocate in interface com.hazelcast.internal.memory.MemoryAllocatorpublic void free(long address,
long size)
Complement of allocate(long).
Only memory allocated by allocate(long) can be
freed using this method.
free in interface com.hazelcast.internal.memory.MemoryAllocatorfree in interface HazelcastMemoryManageraddress - address of memory blocksize - size of memory blockpublic void compact()
HazelcastMemoryManagercompact in interface HazelcastMemoryManagerpublic long getUsableSize(long address)
HazelcastMemoryManagerHazelcastMemoryManager.SIZE_INVALID is returned.getUsableSize in interface HazelcastMemoryManageraddress - address of memory blockHazelcastMemoryManager.SIZE_INVALID if it's unknownpublic long validateAndGetUsableSize(long address)
HazelcastMemoryManagerHazelcastMemoryManager.SIZE_INVALID is returned.validateAndGetUsableSize in interface HazelcastMemoryManageraddress - address of memory blockHazelcastMemoryManager.SIZE_INVALID if it's unknownpublic long getAllocatedSize(long address)
HazelcastMemoryManagerHazelcastMemoryManager.SIZE_INVALID is returned.
Allocated size includes usable memory size plus any header or metadata region size reserved by memory manager.
getAllocatedSize in interface HazelcastMemoryManageraddress - address of memory blockHazelcastMemoryManager.SIZE_INVALID if it's unknownHazelcastMemoryManager.getUsableSize(long)public long validateAndGetAllocatedSize(long address)
HazelcastMemoryManagerHazelcastMemoryManager.SIZE_INVALID is returned.
Allocated size includes usable memory size plus any header or metadata region size reserved by memory manager.
validateAndGetAllocatedSize in interface HazelcastMemoryManageraddress - address of memory blockHazelcastMemoryManager.SIZE_INVALID if it's unknownHazelcastMemoryManager.validateAndGetUsableSize(long)public long newSequence()
HazelcastMemoryManager
Use case for this sequence is to avoid ABA problem by using it with the address
to create a "safe pointer" (address, sequence) to a memory block.
newSequence in interface HazelcastMemoryManagerpublic int getHeaderSize()
public com.hazelcast.memory.GlobalPoolingMemoryManager getGlobalMemoryManager()
public HazelcastMemoryManager getMemoryManager()
public void dispose()
dispose in interface com.hazelcast.nio.Disposablepublic boolean isDisposed()
HazelcastMemoryManagerisDisposed in interface HazelcastMemoryManagertrue if this memory manager is destroyed, false otherwisepublic void registerThread(Thread thread)
protected ThreadLocalPoolingMemoryManager newThreadLocalPoolingMemoryManager(int minBlockSize, int pageSize, LibMalloc malloc, PooledNativeMemoryStats stats)
public void deregisterThread(Thread thread)
public final void gc()
gc in interface GarbageCollectablepublic com.hazelcast.internal.memory.MemoryAllocator getSystemAllocator()
getSystemAllocator in interface HazelcastMemoryManagerpublic com.hazelcast.memory.MemoryStats getMemoryStats()
getMemoryStats in interface HazelcastMemoryManagerpublic void provideMetrics(com.hazelcast.internal.metrics.MetricsRegistry registry)
provideMetrics in interface com.hazelcast.internal.metrics.MetricsProviderCopyright © 2021 Hazelcast, Inc.. All Rights Reserved.