Class NativeMemoryConfig
- java.lang.Object
-
- com.hazelcast.config.NativeMemoryConfig
-
public class NativeMemoryConfig extends java.lang.Object
Configures native memory region.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
andICache
, store their data (entries, indexes etc.) in native memory region when they are configured withInMemoryFormat.NATIVE
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NativeMemoryConfig.MemoryAllocatorType
Type of memory allocator: STANDARD: allocate/free memory using default OS memory manager POOLED: manage memory blocks in pool
-
Field Summary
Fields Modifier and Type Field Description static float
DEFAULT_METADATA_SPACE_PERCENTAGE
Default metadata space percentagestatic int
DEFAULT_MIN_BLOCK_SIZE
Default minimum block size in bytesstatic int
DEFAULT_PAGE_SIZE
Default page size in bytesstatic int
INITIAL_MEMORY_SIZE
Initial memory size in megabytesstatic int
MIN_INITIAL_MEMORY_SIZE
Minimum initial memory size in megabytes
-
Constructor Summary
Constructors Constructor Description NativeMemoryConfig()
NativeMemoryConfig(NativeMemoryConfig nativeMemoryConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
NativeMemoryConfig.MemoryAllocatorType
getAllocatorType()
Returns theNativeMemoryConfig.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.java.lang.String
getPersistentMemoryDirectory()
Deprecated.Since 4.1 multiple persistent memory directories are supported.MemorySize
getSize()
Deprecated.Since 5.2, usegetCapacity()
instead.int
hashCode()
boolean
isEnabled()
Returnstrue
if native memory allocation is enabled,false
otherwise.NativeMemoryConfig
setAllocatorType(NativeMemoryConfig.MemoryAllocatorType allocatorType)
Sets theNativeMemoryConfig.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(java.lang.String directory)
Deprecated.Since 4.1 multiple persistent memory directories are supported.NativeMemoryConfig
setSize(MemorySize capacity)
Deprecated.Since 5.2, usesetCapacity(Capacity)
instead.java.lang.String
toString()
-
-
-
Field Detail
-
DEFAULT_MIN_BLOCK_SIZE
public static final int DEFAULT_MIN_BLOCK_SIZE
Default minimum block size in bytes- See Also:
- Constant Field Values
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZE
Default page size in bytes- See Also:
- Constant Field Values
-
DEFAULT_METADATA_SPACE_PERCENTAGE
public static final float DEFAULT_METADATA_SPACE_PERCENTAGE
Default metadata space percentage- See Also:
- Constant Field Values
-
MIN_INITIAL_MEMORY_SIZE
public static final int MIN_INITIAL_MEMORY_SIZE
Minimum initial memory size in megabytes- See Also:
- Constant Field Values
-
INITIAL_MEMORY_SIZE
public static final int INITIAL_MEMORY_SIZE
Initial memory size in megabytes- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NativeMemoryConfig
public NativeMemoryConfig()
-
NativeMemoryConfig
public NativeMemoryConfig(NativeMemoryConfig nativeMemoryConfig)
-
-
Method Detail
-
getSize
@Deprecated public MemorySize getSize()
Deprecated.Since 5.2, usegetCapacity()
instead.Returns size of the native memory region.
-
setSize
@Deprecated public NativeMemoryConfig setSize(MemorySize capacity)
Deprecated.Since 5.2, usesetCapacity(Capacity)
instead.Sets size of the native memory region.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
.- Parameters:
capacity
- memory size- Returns:
- this
NativeMemoryConfig
instance
-
getCapacity
public Capacity getCapacity()
Returns size (capacity) of the native memory region.
-
setCapacity
public NativeMemoryConfig setCapacity(Capacity capacity)
Sets size (capacity) of the native memory region.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
.- Parameters:
capacity
- memory size- Returns:
- this
NativeMemoryConfig
instance
-
isEnabled
public boolean isEnabled()
Returnstrue
if native memory allocation is enabled,false
otherwise.
-
setEnabled
public NativeMemoryConfig setEnabled(boolean enabled)
Enables or disables native memory allocation.- Returns:
- this
NativeMemoryConfig
instance
-
getAllocatorType
public NativeMemoryConfig.MemoryAllocatorType getAllocatorType()
Returns theNativeMemoryConfig.MemoryAllocatorType
to be used while allocating native memory.
-
setAllocatorType
public NativeMemoryConfig setAllocatorType(NativeMemoryConfig.MemoryAllocatorType allocatorType)
Sets theNativeMemoryConfig.MemoryAllocatorType
to be used while allocating native memory.- Parameters:
allocatorType
-MemoryAllocatorType
- Returns:
- this
NativeMemoryConfig
instance
-
getMinBlockSize
public int getMinBlockSize()
Returns the minimum memory block size, in bytes, to be served by native memory manager. Allocation requests smaller than minimum block size are served with the minimum block size. Default value isDEFAULT_MIN_BLOCK_SIZE
bytes.This configuration is used only by
NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.
-
setMinBlockSize
public NativeMemoryConfig setMinBlockSize(int minBlockSize)
Sets the minimum memory block size, in bytes, to be served by native memory manager. Allocation requests smaller than minimum block size are served with the minimum block size.This configuration is used only by
NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.- Parameters:
minBlockSize
- minimum memory block size- Returns:
- this
NativeMemoryConfig
instance
-
getPageSize
public int getPageSize()
Returns the page size, in bytes, to be allocated by native memory manager as a single block. These page blocks are split into smaller blocks to serve allocation requests. Allocation requests greater than the page size are allocated from system directly, instead of managed memory pool. Default value isDEFAULT_PAGE_SIZE
bytes.This configuration is used only by
NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.
-
setPageSize
public NativeMemoryConfig setPageSize(int pageSize)
Sets the page size, in bytes, to be allocated by native memory manager as a single block. These page blocks are split into smaller blocks to serve allocation requests. Allocation requests greater than the page size are allocated from system directly, instead of managed memory pool.This configuration is used only by
NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.- Parameters:
pageSize
- size of the page- Returns:
- this
NativeMemoryConfig
instance
-
getMetadataSpacePercentage
public float getMetadataSpacePercentage()
Returns the percentage of native memory space to be used to store metadata and internal memory structures by the native memory manager. Default value isDEFAULT_METADATA_SPACE_PERCENTAGE
.This configuration is used only by
NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.
-
setMetadataSpacePercentage
public 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.This configuration is used only by
NativeMemoryConfig.MemoryAllocatorType.POOLED
, otherwise ignored.- Parameters:
metadataSpacePercentage
- percentage of metadata space- Returns:
- this
NativeMemoryConfig
instance
-
getPersistentMemoryConfig
@Nonnull public PersistentMemoryConfig getPersistentMemoryConfig()
Returns the persistent memory configuration this native memory configuration uses.- Returns:
- the persistent memory configuration
-
setPersistentMemoryConfig
public void setPersistentMemoryConfig(@Nonnull PersistentMemoryConfig persistentMemoryConfig)
Sets the persistent memory configuration this native memory configuration uses.- Parameters:
persistentMemoryConfig
- The persistent memory configuration to use
-
getPersistentMemoryDirectory
@Deprecated @Nullable public java.lang.String getPersistentMemoryDirectory()
Deprecated.Since 4.1 multiple persistent memory directories are supported. Please usePersistentMemoryConfig.getDirectoryConfigs()
instead.Returns the persistent memory directory (e.g. Intel Optane) to be used to store memory structures allocated by native memory manager. If there are multiple persistent memory directories are defined inpersistentMemoryConfig
, anIllegalStateException
is thrown.
-
setPersistentMemoryDirectory
@Nonnull @Deprecated public NativeMemoryConfig setPersistentMemoryDirectory(@Nullable java.lang.String directory)
Deprecated.Since 4.1 multiple persistent memory directories are supported. Please usesetPersistentMemoryConfig(PersistentMemoryConfig)
orPersistentMemoryConfig.addDirectoryConfig(PersistentMemoryDirectoryConfig)
instead.Sets the persistent memory directory (e.g. Intel Optane) to be used to store memory structures allocated by native memory manager. If thepersistentMemoryConfig
already contains directory definition, it is overridden with the provideddirectory
.- Parameters:
directory
- the persistent memory directory- Returns:
- this
NativeMemoryConfig
instance - See Also:
getPersistentMemoryConfig()
,PersistentMemoryConfig.addDirectoryConfig(PersistentMemoryDirectoryConfig)
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-