Top Description Fields Constructors Methods
org.lwjgl.system.rpmalloc

public Class RPMallocConfig

extends Struct<RPMallocConfig>
implements NativeResource
Class Inheritance
All Implemented Interfaces
org.lwjgl.system.NativeResource, java.lang.AutoCloseable
Annotations
@NativeType:struct rpmalloc_config_t
Imports
javax.annotation.*, java.nio.*, org.lwjgl.*, org.lwjgl.system.*

This struct enables configuration of a memory mapper providing map/unmap of memory pages. Defaults to 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.

Layout


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);
    void (*error_callback) (char const *message);
    int (*map_fail_callback) (size_t size);
    size_t page_size;
    size_t span_size;
    size_t span_map_count;
    int enable_huge_pages;
    char const * page_name;
    char const * huge_page_name;
}

Field Summary

Modifier and TypeField and Description
public static final int
ALIGNOF

The struct alignment in bytes.

public static final int
ENABLE_HUGE_PAGES

The struct member offsets.

public static final int
ERROR_CALLBACK

The struct member offsets.

public static final int
HUGE_PAGE_NAME

The struct member offsets.

public static final int
MAP_FAIL_CALLBACK

The struct member offsets.

public static final int
MEMORY_MAP

The struct member offsets.

public static final int
MEMORY_UNMAP

The struct member offsets.

public static final int
PAGE_NAME

The struct member offsets.

public static final int
PAGE_SIZE

The struct member offsets.

public static final int
SIZEOF

The struct size in bytes.

public static final int
SPAN_MAP_COUNT

The struct member offsets.

public static final int
SPAN_SIZE

The struct member offsets.

Inherited from org.lwjgl.system.Struct:
containerDEFAULT_ALIGN_ASDEFAULT_PACK_ALIGNMENT

Constructor Summary

AccessConstructor and Description
protected
RPMallocConfig(long address, ByteBuffer container)

public
RPMallocConfig(ByteBuffer container)

Creates a RPMallocConfig instance at the current position of the specified ByteBuffer container.

Method Summary

Modifier and TypeMethod and Description
public static RPMallocConfig
calloc()

Returns a new RPMallocConfig instance allocated with memCalloc.

public static RPMallocConfig
calloc(MemoryStack
the stack from which to allocate
stack
)

Returns a new RPMallocConfig instance allocated on the specified MemoryStack and initializes all its bits to zero.

public static RPMallocConfig
callocStack()

Deprecated
Deprecated for removal in 3.4.0.
public static RPMallocConfig
callocStack(MemoryStack stack)

Deprecated
Deprecated for removal in 3.4.0.
protected RPMallocConfig
create(long
the struct memory address
address
,
ByteBuffer
an optional container buffer, to be referenced strongly by the struct instance.
container
)

Implements abstract org.lwjgl.system.Struct.create.

Similar to the constructor, but returns the exact type of the Struct subclass.
public static RPMallocConfig
create()

Returns a new RPMallocConfig instance allocated with BufferUtils.

public static RPMallocConfig
create(long address)

Returns a new RPMallocConfig instance for the specified memory address.

public static RPMallocConfig
createSafe(long address)

Like create, but returns null if address is NULL.

public boolean
enable_huge_pages()

enable use of large/huge pages.

public RPMallocConfig
enable_huge_pages(boolean value)

Sets the specified value to the enable_huge_pages field.

public RPErrorCallback
error_callback()

the error callback function

public RPMallocConfig
error_callback(RPErrorCallbackI value)

Sets the specified value to the error_callback field.

public ByteBuffer
huge_page_name()

huge allocated pages name for systems supporting it to be able to distinguish among anonymous regions

public RPMallocConfig
huge_page_name(ByteBuffer value)

Sets the address of the specified encoded string to the huge_page_name field.

public String
huge_page_nameString()

huge allocated pages name for systems supporting it to be able to distinguish among anonymous regions

public static RPMallocConfig
malloc()

Returns a new RPMallocConfig instance allocated with memAlloc.

public static RPMallocConfig
malloc(MemoryStack
the stack from which to allocate
stack
)

Returns a new RPMallocConfig instance allocated on the specified MemoryStack.

public static RPMallocConfig
mallocStack()

Deprecated
Deprecated for removal in 3.4.0.
public static RPMallocConfig
mallocStack(MemoryStack stack)

Deprecated
Deprecated for removal in 3.4.0.
public RPMapFailCallback
map_fail_callback()

the map fail callback function

public RPMallocConfig
map_fail_callback(RPMapFailCallbackI value)

Sets the specified value to the map_fail_callback field.

public RPMemoryMapCallback
memory_map()

the memory map callback function

public RPMallocConfig
memory_map(RPMemoryMapCallbackI value)

Sets the specified value to the memory_map field.

public RPMemoryUnmapCallback
memory_unmap()

the memory unmap callback function

public RPMallocConfig
memory_unmap(RPMemoryUnmapCallbackI value)

Sets the specified value to the memory_unmap field.

public static int
nenable_huge_pages(long struct)

Unsafe version of enable_huge_pages.

public static void
nenable_huge_pages(long struct, int value)

Unsafe version of enable_huge_pages.

public static RPErrorCallback
nerror_callback(long struct)

Unsafe version of error_callback.

public static void
nerror_callback(long struct, RPErrorCallbackI value)

Unsafe version of error_callback.

public static ByteBuffer
nhuge_page_name(long struct)

Unsafe version of huge_page_name.

public static void
nhuge_page_name(long struct, ByteBuffer value)

Unsafe version of huge_page_name.

public static String
nhuge_page_nameString(long struct)

Unsafe version of huge_page_nameString.

public static RPMapFailCallback
nmap_fail_callback(long struct)

Unsafe version of map_fail_callback.

public static void
nmap_fail_callback(long struct, RPMapFailCallbackI value)

Unsafe version of map_fail_callback.

public static RPMemoryMapCallback
nmemory_map(long struct)

Unsafe version of memory_map.

public static void
nmemory_map(long struct, RPMemoryMapCallbackI value)

Unsafe version of memory_map.

public static RPMemoryUnmapCallback
nmemory_unmap(long struct)

Unsafe version of memory_unmap.

public static void
nmemory_unmap(long struct, RPMemoryUnmapCallbackI value)

Unsafe version of memory_unmap.

public static ByteBuffer
npage_name(long struct)

Unsafe version of page_name.

public static void
npage_name(long struct, ByteBuffer value)

Unsafe version of page_name.

public static String
npage_nameString(long struct)

Unsafe version of page_nameString.

public static long
npage_size(long struct)

Unsafe version of page_size.

public static void
npage_size(long struct, long value)

Unsafe version of page_size.

public static long
nspan_map_count(long struct)

Unsafe version of span_map_count.

public static void
nspan_map_count(long struct, long value)

Unsafe version of span_map_count.

public static long
nspan_size(long struct)

Unsafe version of span_size.

public static void
nspan_size(long struct, long value)

Unsafe version of span_size.

public ByteBuffer
page_name()

allocated pages name for systems supporting it to be able to distinguish among anonymous regions

public RPMallocConfig
page_name(ByteBuffer value)

Sets the address of the specified encoded string to the page_name field.

public String
page_nameString()

allocated pages name for systems supporting it to be able to distinguish among anonymous regions

public long
page_size()

the size of memory pages.

public RPMallocConfig
page_size(long value)

Sets the specified value to the page_size field.

public RPMallocConfig
set(RPMemoryMapCallbackI memory_map, RPMemoryUnmapCallbackI memory_unmap, RPErrorCallbackI error_callback, RPMapFailCallbackI map_fail_callback, long page_size, long span_size, long span_map_count, boolean enable_huge_pages, ByteBuffer page_name, ByteBuffer huge_page_name)

Initializes this struct with the specified values.

public RPMallocConfig

Returns:

this struct
set
(RPMallocConfig
the source struct
src
)

Copies the specified struct data to this struct.

public int
sizeof()

Implements abstract org.lwjgl.system.Struct.sizeof.

Returns sizeof(struct).
public long
span_map_count()

number of spans to map at each request to map new virtual memory blocks.

public RPMallocConfig
span_map_count(long value)

Sets the specified value to the span_map_count field.

public long
span_size()

size of a span of memory blocks.

public RPMallocConfig
span_size(long value)

Sets the specified value to the span_size field.

Inherited from org.lwjgl.system.Struct:
__array__array__array__checkContainer__checkMalloc__create__getContainer__getContainer__member__member__member__padding__padding__struct__struct__union__unionclearfreeisNullvalidate

Field Detail

ALIGNOFback to summary
public static final int ALIGNOF

The struct alignment in bytes.

ENABLE_HUGE_PAGESback to summary
public static final int ENABLE_HUGE_PAGES

The struct member offsets.

ERROR_CALLBACKback to summary
public static final int ERROR_CALLBACK

The struct member offsets.

HUGE_PAGE_NAMEback to summary
public static final int HUGE_PAGE_NAME

The struct member offsets.

MAP_FAIL_CALLBACKback to summary
public static final int MAP_FAIL_CALLBACK

The struct member offsets.

MEMORY_MAPback to summary
public static final int MEMORY_MAP

The struct member offsets.

MEMORY_UNMAPback to summary
public static final int MEMORY_UNMAP

The struct member offsets.

PAGE_NAMEback to summary
public static final int PAGE_NAME

The struct member offsets.

PAGE_SIZEback to summary
public static final int PAGE_SIZE

The struct member offsets.

SIZEOFback to summary
public static final int SIZEOF

The struct size in bytes.

SPAN_MAP_COUNTback to summary
public static final int SPAN_MAP_COUNT

The struct member offsets.

SPAN_SIZEback to summary
public static final int SPAN_SIZE

The struct member offsets.

Constructor Detail

RPMallocConfigback to summary
protected RPMallocConfig(long address, ByteBuffer container)
RPMallocConfigback to summary
public RPMallocConfig(ByteBuffer container)

Creates a 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.

Method Detail

callocback to summary
public static RPMallocConfig calloc()

Returns a new RPMallocConfig instance allocated with memCalloc. The instance must be explicitly freed.

callocback to summary
public static RPMallocConfig calloc(MemoryStack stack)

Returns a new RPMallocConfig instance allocated on the specified MemoryStack and initializes all its bits to zero.

Parameters
stack:MemoryStack

the stack from which to allocate

callocStackback to summary
public static RPMallocConfig callocStack()

Deprecated

Deprecated for removal in 3.4.0. Use calloc(MemoryStack) instead.

Annotations
@Deprecated
callocStackback to summary
public static RPMallocConfig callocStack(MemoryStack stack)

Deprecated

Deprecated for removal in 3.4.0. Use calloc(MemoryStack) instead.

Annotations
@Deprecated
createback to summary
protected RPMallocConfig create(long address, ByteBuffer container)

Implements abstract org.lwjgl.system.Struct.create.

Doc from org.lwjgl.system.Struct.create.

Similar to the constructor, but returns the exact type of the Struct subclass.

Effectively, every Struct instance is a factory for more instances of the same type. This is used by StructBuffer.

Parameters
address:long

the struct memory address

container:ByteBuffer

an optional container buffer, to be referenced strongly by the struct instance.

Annotations
@Override
createback to summary
public static RPMallocConfig create()

Returns a new RPMallocConfig instance allocated with BufferUtils.

createback to summary
public static RPMallocConfig create(long address)

Returns a new RPMallocConfig instance for the specified memory address.

createSafeback to summary
public static RPMallocConfig createSafe(long address)

Like create, but returns null if address is NULL.

Annotations
@Nullable
enable_huge_pagesback to summary
public boolean 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.

Annotations
@NativeType:int
enable_huge_pagesback to summary
public RPMallocConfig enable_huge_pages(boolean value)

Sets the specified value to the enable_huge_pages field.

error_callbackback to summary
public RPErrorCallback error_callback()

the error callback function

Annotations
@Nullable
@NativeType:void (*) (char const *)
error_callbackback to summary
public RPMallocConfig error_callback(RPErrorCallbackI value)

Sets the specified value to the error_callback field.

huge_page_nameback to summary
public ByteBuffer huge_page_name()

huge allocated pages name for systems supporting it to be able to distinguish among anonymous regions

Annotations
@Nullable
@NativeType:char const *
huge_page_nameback to summary
public RPMallocConfig huge_page_name(ByteBuffer value)

Sets the address of the specified encoded string to the huge_page_name field.

huge_page_nameStringback to summary
public String huge_page_nameString()

huge allocated pages name for systems supporting it to be able to distinguish among anonymous regions

Annotations
@Nullable
@NativeType:char const *
mallocback to summary
public static RPMallocConfig malloc()

Returns a new RPMallocConfig instance allocated with memAlloc. The instance must be explicitly freed.

mallocback to summary
public static RPMallocConfig malloc(MemoryStack stack)

Returns a new RPMallocConfig instance allocated on the specified MemoryStack.

Parameters
stack:MemoryStack

the stack from which to allocate

mallocStackback to summary
public static RPMallocConfig mallocStack()

Deprecated

Deprecated for removal in 3.4.0. Use malloc(MemoryStack) instead.

Annotations
@Deprecated
mallocStackback to summary
public static RPMallocConfig mallocStack(MemoryStack stack)

Deprecated

Deprecated for removal in 3.4.0. Use malloc(MemoryStack) instead.

Annotations
@Deprecated
map_fail_callbackback to summary
public RPMapFailCallback map_fail_callback()

the map fail callback function

Annotations
@Nullable
@NativeType:int (*) (size_t)
map_fail_callbackback to summary
public RPMallocConfig map_fail_callback(RPMapFailCallbackI value)

Sets the specified value to the map_fail_callback field.

memory_mapback to summary
public RPMemoryMapCallback memory_map()

the memory map callback function

Annotations
@Nullable
@NativeType:void * (*) (size_t, size_t *)
memory_mapback to summary
public RPMallocConfig memory_map(RPMemoryMapCallbackI value)

Sets the specified value to the memory_map field.

memory_unmapback to summary
public RPMemoryUnmapCallback memory_unmap()

the memory unmap callback function

Annotations
@Nullable
@NativeType:void (*) (void *, size_t, size_t, int)
memory_unmapback to summary
public RPMallocConfig memory_unmap(RPMemoryUnmapCallbackI value)

Sets the specified value to the memory_unmap field.

nenable_huge_pagesback to summary
public static int nenable_huge_pages(long struct)

Unsafe version of enable_huge_pages.

nenable_huge_pagesback to summary
public static void nenable_huge_pages(long struct, int value)

Unsafe version of enable_huge_pages.

nerror_callbackback to summary
public static RPErrorCallback nerror_callback(long struct)

Unsafe version of error_callback.

Annotations
@Nullable
nerror_callbackback to summary
public static void nerror_callback(long struct, RPErrorCallbackI value)

Unsafe version of error_callback.

nhuge_page_nameback to summary
public static ByteBuffer nhuge_page_name(long struct)

Unsafe version of huge_page_name.

Annotations
@Nullable
nhuge_page_nameback to summary
public static void nhuge_page_name(long struct, ByteBuffer value)

Unsafe version of huge_page_name.

nhuge_page_nameStringback to summary
public static String nhuge_page_nameString(long struct)

Unsafe version of huge_page_nameString.

Annotations
@Nullable
nmap_fail_callbackback to summary
public static RPMapFailCallback nmap_fail_callback(long struct)

Unsafe version of map_fail_callback.

Annotations
@Nullable
nmap_fail_callbackback to summary
public static void nmap_fail_callback(long struct, RPMapFailCallbackI value)

Unsafe version of map_fail_callback.

nmemory_mapback to summary
public static RPMemoryMapCallback nmemory_map(long struct)

Unsafe version of memory_map.

Annotations
@Nullable
nmemory_mapback to summary
public static void nmemory_map(long struct, RPMemoryMapCallbackI value)

Unsafe version of memory_map.

nmemory_unmapback to summary
public static RPMemoryUnmapCallback nmemory_unmap(long struct)

Unsafe version of memory_unmap.

Annotations
@Nullable
nmemory_unmapback to summary
public static void nmemory_unmap(long struct, RPMemoryUnmapCallbackI value)

Unsafe version of memory_unmap.

npage_nameback to summary
public static ByteBuffer npage_name(long struct)

Unsafe version of page_name.

Annotations
@Nullable
npage_nameback to summary
public static void npage_name(long struct, ByteBuffer value)

Unsafe version of page_name.

npage_nameStringback to summary
public static String npage_nameString(long struct)

Unsafe version of page_nameString.

Annotations
@Nullable
npage_sizeback to summary
public static long npage_size(long struct)

Unsafe version of page_size.

npage_sizeback to summary
public static void npage_size(long struct, long value)

Unsafe version of page_size.

nspan_map_countback to summary
public static long nspan_map_count(long struct)

Unsafe version of span_map_count.

nspan_map_countback to summary
public static void nspan_map_count(long struct, long value)

Unsafe version of span_map_count.

nspan_sizeback to summary
public static long nspan_size(long struct)

Unsafe version of span_size.

nspan_sizeback to summary
public static void nspan_size(long struct, long value)

Unsafe version of span_size.

page_nameback to summary
public ByteBuffer page_name()

allocated pages name for systems supporting it to be able to distinguish among anonymous regions

Annotations
@Nullable
@NativeType:char const *
page_nameback to summary
public RPMallocConfig page_name(ByteBuffer value)

Sets the address of the specified encoded string to the page_name field.

page_nameStringback to summary
public String page_nameString()

allocated pages name for systems supporting it to be able to distinguish among anonymous regions

Annotations
@Nullable
@NativeType:char const *
page_sizeback to summary
public long page_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.

Annotations
@NativeType:size_t
page_sizeback to summary
public RPMallocConfig page_size(long value)

Sets the specified value to the page_size field.

setback to summary
public RPMallocConfig set(RPMemoryMapCallbackI memory_map, RPMemoryUnmapCallbackI memory_unmap, RPErrorCallbackI error_callback, RPMapFailCallbackI map_fail_callback, long page_size, long span_size, long span_map_count, boolean enable_huge_pages, ByteBuffer page_name, ByteBuffer huge_page_name)

Initializes this struct with the specified values.

setback to summary
public RPMallocConfig set(RPMallocConfig src)

Copies the specified struct data to this struct.

Parameters
src:RPMallocConfig

the source struct

Returns:RPMallocConfig

this struct

sizeofback to summary
public int sizeof()

Implements abstract org.lwjgl.system.Struct.sizeof.

Doc from org.lwjgl.system.Struct.sizeof.

Returns sizeof(struct).

Annotations
@Override
span_map_countback to summary
public long 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.

Annotations
@NativeType:size_t
span_map_countback to summary
public RPMallocConfig span_map_count(long value)

Sets the specified value to the span_map_count field.

span_sizeback to summary
public long 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.

Annotations
@NativeType:size_t
span_sizeback to summary
public RPMallocConfig span_size(long value)

Sets the specified value to the span_size field.