public class NativeMemoryConfig extends Object
Native memory is allocated outside JVM heap space and is not subject to JVM garbage collection. Therefore, hundreds of gigabytes of native memory can be allocated & used without introducing pressure on GC mechanism.
Data structures, such as IMap
and ICache
,
store their data (entries, indexes etc.) in native memory region when they are configured with
InMemoryFormat.NATIVE
.
Modifier and Type | Class and Description |
---|---|
static class |
NativeMemoryConfig.MemoryAllocatorType
Type of memory allocator:
STANDARD: allocate/free memory using default OS memory manager
POOLED: manage memory blocks in pool
|
Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_METADATA_SPACE_PERCENTAGE
Default metadata space percentage
|
static int |
DEFAULT_MIN_BLOCK_SIZE
Default minimum block size in bytes
|
static int |
DEFAULT_PAGE_SIZE
Default page size in bytes
|
static int |
INITIAL_MEMORY_SIZE
Initial memory size in megabytes
|
static int |
MIN_INITIAL_MEMORY_SIZE
Minimum initial memory size in megabytes
|
Constructor and Description |
---|
NativeMemoryConfig() |
NativeMemoryConfig(NativeMemoryConfig nativeMemoryConfig) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
NativeMemoryConfig.MemoryAllocatorType |
getAllocatorType()
Returns the
NativeMemoryConfig.MemoryAllocatorType to be used while allocating native memory. |
Capacity |
getCapacity()
Returns size (capacity) of the native memory region.
|
float |
getMetadataSpacePercentage()
Returns the percentage of native memory space to be used to store metadata and internal memory structures
by the native memory manager.
|
int |
getMinBlockSize()
Returns the minimum memory block size, in bytes, to be served by native memory manager.
|
int |
getPageSize()
Returns the page size, in bytes, to be allocated by native memory manager as a single block.
|
PersistentMemoryConfig |
getPersistentMemoryConfig()
Returns the persistent memory configuration this native memory
configuration uses.
|
String |
getPersistentMemoryDirectory()
Deprecated.
Since 4.1 multiple persistent memory directories are
supported. Please use
PersistentMemoryConfig.getDirectoryConfigs()
instead. |
MemorySize |
getSize()
Deprecated.
Since 5.2, use
getCapacity() instead. |
int |
hashCode() |
boolean |
isEnabled()
Returns
true if native memory allocation is enabled, false otherwise. |
NativeMemoryConfig |
setAllocatorType(NativeMemoryConfig.MemoryAllocatorType allocatorType)
Sets the
NativeMemoryConfig.MemoryAllocatorType to be used while allocating native memory. |
NativeMemoryConfig |
setCapacity(Capacity capacity)
Sets size (capacity) of the native memory region.
|
NativeMemoryConfig |
setEnabled(boolean enabled)
Enables or disables native memory allocation.
|
NativeMemoryConfig |
setMetadataSpacePercentage(float metadataSpacePercentage)
Sets the percentage of native memory space to be used to store metadata and internal memory structures
by the native memory manager.
|
NativeMemoryConfig |
setMinBlockSize(int minBlockSize)
Sets the minimum memory block size, in bytes, to be served by native memory manager.
|
NativeMemoryConfig |
setPageSize(int pageSize)
Sets the page size, in bytes, to be allocated by native memory manager as a single block.
|
void |
setPersistentMemoryConfig(PersistentMemoryConfig persistentMemoryConfig)
Sets the persistent memory configuration this native memory
configuration uses.
|
NativeMemoryConfig |
setPersistentMemoryDirectory(String directory)
Deprecated.
Since 4.1 multiple persistent memory directories are
supported. Please use
setPersistentMemoryConfig(PersistentMemoryConfig)
or PersistentMemoryConfig.addDirectoryConfig(PersistentMemoryDirectoryConfig)
instead. |
NativeMemoryConfig |
setSize(MemorySize capacity)
Deprecated.
Since 5.2, use
setCapacity(Capacity) instead. |
String |
toString() |
public static final int DEFAULT_MIN_BLOCK_SIZE
public static final int DEFAULT_PAGE_SIZE
public static final float DEFAULT_METADATA_SPACE_PERCENTAGE
public static final int MIN_INITIAL_MEMORY_SIZE
public static final int INITIAL_MEMORY_SIZE
public NativeMemoryConfig()
public NativeMemoryConfig(NativeMemoryConfig nativeMemoryConfig)
@Deprecated public MemorySize getSize()
getCapacity()
instead.@Deprecated public NativeMemoryConfig setSize(MemorySize capacity)
setCapacity(Capacity)
instead.
Total size of the memory blocks allocated in native memory region cannot exceed this memory size.
When native memory region is completely allocated and in-use, further allocation requests will fail
with NativeOutOfMemoryError
.
capacity
- memory sizeNativeMemoryConfig
instancepublic Capacity getCapacity()
public NativeMemoryConfig setCapacity(Capacity capacity)
Total capacity of the memory blocks allocated in native memory region cannot exceed this memory size.
When native memory region is completely allocated and in-use, further allocation requests will fail
with NativeOutOfMemoryError
.
capacity
- memory sizeNativeMemoryConfig
instancepublic boolean isEnabled()
true
if native memory allocation is enabled, false
otherwise.public NativeMemoryConfig setEnabled(boolean enabled)
NativeMemoryConfig
instancepublic NativeMemoryConfig.MemoryAllocatorType getAllocatorType()
NativeMemoryConfig.MemoryAllocatorType
to be used while allocating native memory.public NativeMemoryConfig setAllocatorType(NativeMemoryConfig.MemoryAllocatorType allocatorType)
NativeMemoryConfig.MemoryAllocatorType
to be used while allocating native memory.allocatorType
- MemoryAllocatorType
NativeMemoryConfig
instancepublic int getMinBlockSize()
DEFAULT_MIN_BLOCK_SIZE
bytes.
This configuration is used only by NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.
public NativeMemoryConfig setMinBlockSize(int minBlockSize)
This configuration is used only by NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.
minBlockSize
- minimum memory block sizeNativeMemoryConfig
instancepublic int getPageSize()
DEFAULT_PAGE_SIZE
bytes.
This configuration is used only by NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.
public NativeMemoryConfig setPageSize(int pageSize)
This configuration is used only by NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.
pageSize
- size of the pageNativeMemoryConfig
instancepublic float getMetadataSpacePercentage()
DEFAULT_METADATA_SPACE_PERCENTAGE
.
This configuration is used only by NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.
public NativeMemoryConfig setMetadataSpacePercentage(float metadataSpacePercentage)
This configuration is used only by NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.
metadataSpacePercentage
- percentage of metadata spaceNativeMemoryConfig
instance@Nonnull public PersistentMemoryConfig getPersistentMemoryConfig()
public void setPersistentMemoryConfig(@Nonnull PersistentMemoryConfig persistentMemoryConfig)
persistentMemoryConfig
- The persistent memory configuration to use@Deprecated @Nullable public String getPersistentMemoryDirectory()
PersistentMemoryConfig.getDirectoryConfigs()
instead.persistentMemoryConfig
, an IllegalStateException
is thrown.@Nonnull @Deprecated public NativeMemoryConfig setPersistentMemoryDirectory(@Nullable String directory)
setPersistentMemoryConfig(PersistentMemoryConfig)
or PersistentMemoryConfig.addDirectoryConfig(PersistentMemoryDirectoryConfig)
instead.persistentMemoryConfig
already contains directory
definition, it is overridden with the provided directory
.directory
- the persistent memory directoryNativeMemoryConfig
instancegetPersistentMemoryConfig()
,
PersistentMemoryConfig.addDirectoryConfig(PersistentMemoryDirectoryConfig)
Copyright © 2023 Hazelcast, Inc.. All rights reserved.