public class RPMallocConfig
extends org.lwjgl.system.Struct
implements org.lwjgl.system.NativeResource
VirtualAlloc/mmap if none
provided. This allows rpmalloc to be used in contexts where memory is provided by internal means.
Page size may be set explicitly in initialization. This allows the allocator to be used as a sub-allocator where the page granularity should be lower to reduce risk of wasting unused memory ranges.
If rpmalloc is built with ENABLE_GUARDS, memory_overwrite may be set to detect writes before or after allocated memory blocks. This is
not enabled in the default LWJGL build.
memory_map – the memory map callback functionmemory_unmap – the memory unmap callback functionpage_size –
the size of memory pages.
The page size MUST be a power of two in [512,16384] range (29 to 214) unless 0 - set to 0 to use system page size. All
memory mapping requests to memory_map will be made with size set to a multiple of the page size.
Used if RPMALLOC_CONFIGURABLE is defined to 1, otherwise system page size is used.
span_size –
size of a span of memory blocks.
MUST be a power of two, and in [4096,262144] range (unless 0 - set to 0 to use the default span size).
Used if RPMALLOC_CONFIGURABLE is defined to 1.
span_map_count –
number of spans to map at each request to map new virtual memory blocks.
This can be used to minimize the system call overhead at the cost of virtual memory address space. The extra mapped pages will not be written until actually used, so physical committed memory should not be affected in the default implementation.
Will be aligned to a multiple of spans that match memory page size in case of huge pages.
enable_huge_pages –
enable use of large/huge pages.
If this flag is set to non-zero and page size is zero, the allocator will try to enable huge pages and auto detect the configuration. If this is set to non-zero and page_size is also non-zero, the allocator will assume huge pages have been configured and enabled prior to initializing the allocator.
For Windows, see large-page-support. For Linux, see hugetlbpage.txt.
struct rpmalloc_config_t {
void * (*memory_map) (size_t size, size_t *offset);
void (*memory_unmap) (void *address, size_t size, size_t offset, int release);
size_t page_size;
size_t span_size;
size_t span_map_count;
int enable_huge_pages;
}| Modifier and Type | Field and Description |
|---|---|
static int |
ALIGNOF
The struct alignment in bytes.
|
static int |
ENABLE_HUGE_PAGES
The struct member offsets.
|
static int |
MEMORY_MAP
The struct member offsets.
|
static int |
MEMORY_UNMAP
The struct member offsets.
|
static int |
PAGE_SIZE
The struct member offsets.
|
static int |
SIZEOF
The struct size in bytes.
|
static int |
SPAN_MAP_COUNT
The struct member offsets.
|
static int |
SPAN_SIZE
The struct member offsets.
|
| Constructor and Description |
|---|
RPMallocConfig(java.nio.ByteBuffer container)
Creates a
RPMallocConfig instance at the current position of the specified ByteBuffer container. |
| Modifier and Type | Method and Description |
|---|---|
static RPMallocConfig |
calloc()
Returns a new
RPMallocConfig instance allocated with memCalloc. |
static RPMallocConfig |
callocStack()
Returns a new
RPMallocConfig instance allocated on the thread-local MemoryStack and initializes all its bits to zero. |
static RPMallocConfig |
callocStack(org.lwjgl.system.MemoryStack stack)
Returns a new
RPMallocConfig instance allocated on the specified MemoryStack and initializes all its bits to zero. |
static RPMallocConfig |
create()
Returns a new
RPMallocConfig instance allocated with BufferUtils. |
static RPMallocConfig |
create(long address)
Returns a new
RPMallocConfig instance for the specified memory address. |
static RPMallocConfig |
createSafe(long address)
|
boolean |
enable_huge_pages()
Returns the value of the
enable_huge_pages field. |
RPMallocConfig |
enable_huge_pages(boolean value)
Sets the specified value to the
enable_huge_pages field. |
static RPMallocConfig |
malloc()
Returns a new
RPMallocConfig instance allocated with memAlloc. |
static RPMallocConfig |
mallocStack()
Returns a new
RPMallocConfig instance allocated on the thread-local MemoryStack. |
static RPMallocConfig |
mallocStack(org.lwjgl.system.MemoryStack stack)
Returns a new
RPMallocConfig instance allocated on the specified MemoryStack. |
RPMemoryMapCallback |
memory_map()
Returns the value of the
memory_map field. |
RPMallocConfig |
memory_map(RPMemoryMapCallbackI value)
Sets the specified value to the
memory_map field. |
RPMemoryUnmapCallback |
memory_unmap()
Returns the value of the
memory_unmap field. |
RPMallocConfig |
memory_unmap(RPMemoryUnmapCallbackI value)
Sets the specified value to the
memory_unmap field. |
static int |
nenable_huge_pages(long struct)
Unsafe version of
enable_huge_pages(). |
static void |
nenable_huge_pages(long struct,
int value)
Unsafe version of
enable_huge_pages. |
static RPMemoryMapCallback |
nmemory_map(long struct)
Unsafe version of
memory_map(). |
static void |
nmemory_map(long struct,
RPMemoryMapCallbackI value)
Unsafe version of
memory_map. |
static RPMemoryUnmapCallback |
nmemory_unmap(long struct)
Unsafe version of
memory_unmap(). |
static void |
nmemory_unmap(long struct,
RPMemoryUnmapCallbackI value)
Unsafe version of
memory_unmap. |
static long |
npage_size(long struct)
Unsafe version of
page_size(). |
static void |
npage_size(long struct,
long value)
Unsafe version of
page_size. |
static long |
nspan_map_count(long struct)
Unsafe version of
span_map_count(). |
static void |
nspan_map_count(long struct,
long value)
Unsafe version of
span_map_count. |
static long |
nspan_size(long struct)
Unsafe version of
span_size(). |
static void |
nspan_size(long struct,
long value)
Unsafe version of
span_size. |
long |
page_size()
Returns the value of the
page_size field. |
RPMallocConfig |
page_size(long value)
Sets the specified value to the
page_size field. |
RPMallocConfig |
set(RPMallocConfig src)
Copies the specified struct data to this struct.
|
RPMallocConfig |
set(RPMemoryMapCallbackI memory_map,
RPMemoryUnmapCallbackI memory_unmap,
long page_size,
long span_size,
long span_map_count,
boolean enable_huge_pages)
Initializes this struct with the specified values.
|
int |
sizeof() |
long |
span_map_count()
Returns the value of the
span_map_count field. |
RPMallocConfig |
span_map_count(long value)
Sets the specified value to the
span_map_count field. |
long |
span_size()
Returns the value of the
span_size field. |
RPMallocConfig |
span_size(long value)
Sets the specified value to the
span_size field. |
public static final int SIZEOF
public static final int ALIGNOF
public static final int MEMORY_MAP
public static final int MEMORY_UNMAP
public static final int PAGE_SIZE
public static final int SPAN_SIZE
public static final int SPAN_MAP_COUNT
public static final int ENABLE_HUGE_PAGES
public RPMallocConfig(java.nio.ByteBuffer container)
RPMallocConfig instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be
visible to the struct instance and vice versa.
The created instance holds a strong reference to the container object.
public int sizeof()
sizeof in class org.lwjgl.system.Struct@Nullable public RPMemoryMapCallback memory_map()
memory_map field.@Nullable public RPMemoryUnmapCallback memory_unmap()
memory_unmap field.public long page_size()
page_size field.public long span_size()
span_size field.public long span_map_count()
span_map_count field.public boolean enable_huge_pages()
enable_huge_pages field.public RPMallocConfig memory_map(@Nullable RPMemoryMapCallbackI value)
memory_map field.public RPMallocConfig memory_unmap(@Nullable RPMemoryUnmapCallbackI value)
memory_unmap field.public RPMallocConfig page_size(long value)
page_size field.public RPMallocConfig span_size(long value)
span_size field.public RPMallocConfig span_map_count(long value)
span_map_count field.public RPMallocConfig enable_huge_pages(boolean value)
enable_huge_pages field.public RPMallocConfig set(RPMemoryMapCallbackI memory_map, RPMemoryUnmapCallbackI memory_unmap, long page_size, long span_size, long span_map_count, boolean enable_huge_pages)
public RPMallocConfig set(RPMallocConfig src)
src - the source structpublic static RPMallocConfig malloc()
RPMallocConfig instance allocated with memAlloc. The instance must be explicitly freed.public static RPMallocConfig calloc()
RPMallocConfig instance allocated with memCalloc. The instance must be explicitly freed.public static RPMallocConfig create()
RPMallocConfig instance allocated with BufferUtils.public static RPMallocConfig create(long address)
RPMallocConfig instance for the specified memory address.@Nullable public static RPMallocConfig createSafe(long address)
public static RPMallocConfig mallocStack()
RPMallocConfig instance allocated on the thread-local MemoryStack.public static RPMallocConfig callocStack()
RPMallocConfig instance allocated on the thread-local MemoryStack and initializes all its bits to zero.public static RPMallocConfig mallocStack(org.lwjgl.system.MemoryStack stack)
RPMallocConfig instance allocated on the specified MemoryStack.stack - the stack from which to allocatepublic static RPMallocConfig callocStack(org.lwjgl.system.MemoryStack stack)
RPMallocConfig instance allocated on the specified MemoryStack and initializes all its bits to zero.stack - the stack from which to allocate@Nullable public static RPMemoryMapCallback nmemory_map(long struct)
memory_map().@Nullable public static RPMemoryUnmapCallback nmemory_unmap(long struct)
memory_unmap().public static long npage_size(long struct)
page_size().public static long nspan_size(long struct)
span_size().public static long nspan_map_count(long struct)
span_map_count().public static int nenable_huge_pages(long struct)
enable_huge_pages().public static void nmemory_map(long struct,
@Nullable
RPMemoryMapCallbackI value)
memory_map.public static void nmemory_unmap(long struct,
@Nullable
RPMemoryUnmapCallbackI value)
memory_unmap.public static void npage_size(long struct,
long value)
page_size.public static void nspan_size(long struct,
long value)
span_size.public static void nspan_map_count(long struct,
long value)
span_map_count.public static void nenable_huge_pages(long struct,
int value)
enable_huge_pages.Copyright LWJGL. All Rights Reserved. License terms.