public final class StandardMemoryManager extends Object implements HazelcastMemoryManager, com.hazelcast.internal.metrics.MetricsProvider
| Modifier and Type | Field and Description |
|---|---|
static String |
PROPERTY_DEBUG_ENABLED
System property to enable the debug mode of
StandardMemoryManager. |
static String |
PROPERTY_DEBUG_STACKTRACE_ENABLED
System property to enable the debug mode with stacktraces of
StandardMemoryManager. |
SIZE_INVALID| Constructor and Description |
|---|
StandardMemoryManager(com.hazelcast.memory.MemorySize cap) |
StandardMemoryManager(com.hazelcast.memory.MemorySize cap,
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.
|
protected static void |
checkNotNull(long address,
long size) |
void |
compact()
Compacts the memory region.
|
void |
dispose() |
void |
forEachAllocatedBlock(com.hazelcast.util.function.LongLongConsumer consumer) |
void |
free(long address,
long size)
Gives allocated memory block back to internal pool or to OS
if pool is over capacity.
|
long |
getAllocatedSize(long address)
Returns allocated size of memory block as if it belongs to and is allocated by this memory manager.
|
com.hazelcast.util.collection.Long2ObjectHashMap<String> |
getAllocatedStackTraces() |
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.
|
void |
provideMetrics(com.hazelcast.internal.metrics.MetricsRegistry registry) |
long |
reallocate(long address,
long currentSize,
long newSize) |
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 static final String PROPERTY_DEBUG_ENABLED
StandardMemoryManager.public static final String PROPERTY_DEBUG_STACKTRACE_ENABLED
StandardMemoryManager.public StandardMemoryManager(com.hazelcast.memory.MemorySize cap)
public StandardMemoryManager(com.hazelcast.memory.MemorySize cap,
FreeMemoryChecker freeMemoryChecker)
public com.hazelcast.memory.MemoryStats getMemoryStats()
getMemoryStats in interface HazelcastMemoryManagerpublic long allocate(long size)
HazelcastMemoryManager
Complement of HazelcastMemoryManager.free(long, long).
Memory allocated by this method should be freed using
HazelcastMemoryManager.free(long, long)
allocate in interface com.hazelcast.internal.memory.MemoryAllocatorallocate in interface HazelcastMemoryManagersize - of requested memory blockpublic long reallocate(long address,
long currentSize,
long newSize)
reallocate in interface com.hazelcast.internal.memory.MemoryAllocatorpublic void free(long address,
long size)
HazelcastMemoryManager
Complement of HazelcastMemoryManager.allocate(long).
Only memory allocated by HazelcastMemoryManager.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 com.hazelcast.internal.memory.MemoryAllocator getSystemAllocator()
getSystemAllocator in interface HazelcastMemoryManagerpublic boolean isDisposed()
HazelcastMemoryManagerisDisposed in interface HazelcastMemoryManagertrue if this memory manager is destroyed, false otherwisepublic void dispose()
dispose in interface com.hazelcast.nio.Disposablepublic 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 void provideMetrics(com.hazelcast.internal.metrics.MetricsRegistry registry)
provideMetrics in interface com.hazelcast.internal.metrics.MetricsProviderpublic void forEachAllocatedBlock(com.hazelcast.util.function.LongLongConsumer consumer)
public com.hazelcast.util.collection.Long2ObjectHashMap<String> getAllocatedStackTraces()
protected static void checkNotNull(long address,
long size)
Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.