Class NativeMemoryConfig
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumType of memory allocator: STANDARD: allocate/free memory using default OS memory manager POOLED: manage memory blocks in pool -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatDefault metadata space percentagestatic final intDefault minimum block size in bytesstatic final intDefault page size in bytesstatic final intInitial memory size in megabytesstatic final intMinimum initial memory size in megabytes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanReturns theNativeMemoryConfig.MemoryAllocatorTypeto be used while allocating native memory.Returns size (capacity) of the native memory region.floatReturns the percentage of native memory space to be used to store metadata and internal memory structures by the native memory manager.intReturns the minimum memory block size, in bytes, to be served by native memory manager.intReturns the page size, in bytes, to be allocated by native memory manager as a single block.Returns the persistent memory configuration this native memory configuration uses.Deprecated.multiple persistent memory directories are supported.getSize()Deprecated.usegetCapacity()instead.final inthashCode()booleanReturnstrueif native memory allocation is enabled,falseotherwise.setAllocatorType(NativeMemoryConfig.MemoryAllocatorType allocatorType) Sets theNativeMemoryConfig.MemoryAllocatorTypeto be used while allocating native memory.setCapacity(Capacity capacity) Sets size (capacity) of the native memory region.setEnabled(boolean enabled) Enables or disables native memory allocation.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.setMinBlockSize(int minBlockSize) Sets the minimum memory block size, in bytes, to be served by native memory manager.setPageSize(int pageSize) Sets the page size, in bytes, to be allocated by native memory manager as a single block.voidsetPersistentMemoryConfig(PersistentMemoryConfig persistentMemoryConfig) Sets the persistent memory configuration this native memory configuration uses.setPersistentMemoryDirectory(String directory) Deprecated.multiple persistent memory directories are supported.setSize(MemorySize capacity) Deprecated.usesetCapacity(Capacity)instead.toString()
-
Field Details
-
DEFAULT_MIN_BLOCK_SIZE
public static final int DEFAULT_MIN_BLOCK_SIZEDefault minimum block size in bytes- See Also:
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZEDefault page size in bytes- See Also:
-
DEFAULT_METADATA_SPACE_PERCENTAGE
public static final float DEFAULT_METADATA_SPACE_PERCENTAGEDefault metadata space percentage- See Also:
-
MIN_INITIAL_MEMORY_SIZE
public static final int MIN_INITIAL_MEMORY_SIZEMinimum initial memory size in megabytes- See Also:
-
INITIAL_MEMORY_SIZE
public static final int INITIAL_MEMORY_SIZEInitial memory size in megabytes- See Also:
-
-
Constructor Details
-
NativeMemoryConfig
public NativeMemoryConfig() -
NativeMemoryConfig
-
-
Method Details
-
getSize
Deprecated.usegetCapacity()instead.Returns size of the native memory region. -
setSize
Deprecated.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
NativeMemoryConfiginstance
-
getCapacity
Returns size (capacity) of the native memory region. -
setCapacity
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
NativeMemoryConfiginstance
-
isEnabled
public boolean isEnabled()Returnstrueif native memory allocation is enabled,falseotherwise. -
setEnabled
Enables or disables native memory allocation.- Returns:
- this
NativeMemoryConfiginstance
-
getAllocatorType
Returns theNativeMemoryConfig.MemoryAllocatorTypeto be used while allocating native memory. -
setAllocatorType
Sets theNativeMemoryConfig.MemoryAllocatorTypeto be used while allocating native memory.- Parameters:
allocatorType-MemoryAllocatorType- Returns:
- this
NativeMemoryConfiginstance
-
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_SIZEbytes.This configuration is used only by
NativeMemoryConfig.MemoryAllocatorType.POOLED, otherwise ignored. -
setMinBlockSize
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
NativeMemoryConfiginstance
-
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_SIZEbytes.This configuration is used only by
NativeMemoryConfig.MemoryAllocatorType.POOLED, otherwise ignored. -
setPageSize
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
NativeMemoryConfiginstance
-
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
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
NativeMemoryConfiginstance
-
getPersistentMemoryConfig
Returns the persistent memory configuration this native memory configuration uses.- Returns:
- the persistent memory configuration
-
setPersistentMemoryConfig
Sets the persistent memory configuration this native memory configuration uses.- Parameters:
persistentMemoryConfig- The persistent memory configuration to use
-
getPersistentMemoryDirectory
Deprecated.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, anIllegalStateExceptionis thrown. -
setPersistentMemoryDirectory
@Nonnull @Deprecated(since="4.1") public NativeMemoryConfig setPersistentMemoryDirectory(@Nullable String directory) Deprecated.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 thepersistentMemoryConfigalready contains directory definition, it is overridden with the provideddirectory.- Parameters:
directory- the persistent memory directory- Returns:
- this
NativeMemoryConfiginstance - See Also:
-
equals
-
hashCode
public final int hashCode() -
toString
-