Top Description Constructors Methods
org.graalvm.nativeimage

public final Class UnmanagedMemory

extends Object
Class Inheritance
Imports
org.graalvm.nativeimage.impl.UnmanagedMemorySupport, org.graalvm.word.PointerBase, .UnsignedWord, .WordFactory

Contains static methods that allow allocate/free of unmanaged memory, i.e., memory that is not under the control of the garbage collector. In a typical C environment, these are the malloc/free functions of the standard C library, however this class makes no assumptions or guarantees about how the memory is managed. In particular, it is not allowed to free memory returned by these allocation function directly using the standard C library (or vice versa).
Since
19.0

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <T extends PointerBase> T
calloc(UnsignedWord size)

Allocates size bytes of unmanaged memory.

public static <T extends PointerBase> T
calloc(int size)

Allocates size bytes of unmanaged memory.

public static void
free(PointerBase ptr)

Frees unmanaged memory that was previously allocated using methods of this class.

public static <T extends PointerBase> T
malloc(UnsignedWord size)

Allocates size bytes of unmanaged memory.

public static <T extends PointerBase> T
malloc(int size)

Allocates size bytes of unmanaged memory.

public static <T extends PointerBase> T
realloc(T ptr, UnsignedWord size)

Changes the size of the provided unmanaged memory to size bytes of unmanaged memory.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

UnmanagedMemoryback to summary
private UnmanagedMemory()

Method Detail

callocback to summary
public static <T extends PointerBase> T calloc(UnsignedWord size)

Allocates size bytes of unmanaged memory. The content of the memory is set to 0.

If size is 0, the method is allowed but not required to return the null pointer. This method never returns a the null pointer, but instead throws a OutOfMemoryError when allocation fails.

Since
19.0
callocback to summary
public static <T extends PointerBase> T calloc(int size)

Allocates size bytes of unmanaged memory. The content of the memory is set to 0.

If size is 0, the method is allowed but not required to return the null pointer. This method never returns a the null pointer, but instead throws a OutOfMemoryError when allocation fails.

Since
19.0
freeback to summary
public static void free(PointerBase ptr)

Frees unmanaged memory that was previously allocated using methods of this class.

Since
19.0
mallocback to summary
public static <T extends PointerBase> T malloc(UnsignedWord size)

Allocates size bytes of unmanaged memory. The content of the memory is undefined.

If size is 0, the method is allowed but not required to return the null pointer. This method never returns a the null pointer, but instead throws a OutOfMemoryError when allocation fails.

Since
19.0
mallocback to summary
public static <T extends PointerBase> T malloc(int size)

Allocates size bytes of unmanaged memory. The content of the memory is undefined.

If size is 0, the method is allowed but not required to return the null pointer. This method never returns a the null pointer, but instead throws a OutOfMemoryError when allocation fails.

Since
19.0
reallocback to summary
public static <T extends PointerBase> T realloc(T ptr, UnsignedWord size)

Changes the size of the provided unmanaged memory to size bytes of unmanaged memory. If the new size is larger than the old size, the content of the additional memory is undefined.

If size is 0, the method is allowed but not required to return the null pointer. This method never returns a the null pointer, but instead throws a OutOfMemoryError when allocation fails.

Since
19.0