Top Description Constructors Methods
jnr.ffi

public final Class Memory

extends Object
Class Inheritance

A utility for allocating memory that can be passed to native functions.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Pointer

Returns:

a Pointer instance that can access the memory.
allocate
(Runtime
The current runtime.
runtime
,
int
The size in bytes of memory to allocate.
size
)

Allocates a new block of java memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocate
(Runtime
The current runtime.
runtime
,
NativeType
The native type to allocate memory for.
type
)

Allocates a new block of java memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocate
(Runtime
The current runtime.
runtime
,
Type
The type to allocate memory for.
type
)

Allocates a new block of java memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocate
(Runtime
The current runtime.
runtime
,
TypeAlias
The type alias to allocate memory for.
type
)

Allocates a new block of java memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocateDirect
(Runtime
The current runtime.
runtime
,
int
The size in bytes of memory to allocate.
size
)

Allocates a new block of native memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocateDirect
(Runtime
The current runtime.
runtime
,
long
The size in bytes of memory to allocate.
size
)

Allocates a new block of native memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocateDirect
(Runtime
The current runtime.
runtime
,
NativeType
The native type to allocate memory for.
type
)

Allocates a new block of native memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocateDirect
(Runtime
The current runtime.
runtime
,
TypeAlias
The type alias to allocate memory for.
type
)

Allocates a new block of native memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocateDirect
(Runtime
The current runtime.
runtime
,
int
The size in bytes of memory to allocate.
size
,
boolean
Whether the memory contents should be cleared, or left as random data.
clear
)

Allocates a new block of native memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocateDirect
(Runtime
The current runtime.
runtime
,
long
The size in bytes of memory to allocate.
size
,
boolean
Whether the memory contents should be cleared, or left as random data.
clear
)

Allocates a new block of native memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocateTemporary
(Runtime
The current runtime.
runtime
,
NativeType
The native type to allocate memory for.
type
)

Allocates a new block of transient native memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocateTemporary
(Runtime
The current runtime.
runtime
,
TypeAlias
The type alias to allocate memory for.
type
)

Allocates a new block of transient native memory and wraps it in a Pointer accessor.

public static Pointer

Returns:

a Pointer instance that can access the memory.
allocateTemporary
(Runtime
The current runtime.
runtime
,
NativeType
The native type to allocate memory for.
type
,
boolean
Whether the memory contents should be cleared, or left as random data.
clear
)

Allocates a new block of transient native memory and wraps it in a Pointer accessor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Memoryback to summary
private Memory()

Method Detail

allocateback to summary
public static Pointer allocate(Runtime runtime, int size)

Allocates a new block of java memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

size:int

The size in bytes of memory to allocate.

Returns:Pointer

a Pointer instance that can access the memory.

allocateback to summary
public static Pointer allocate(Runtime runtime, NativeType type)

Allocates a new block of java memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

type:NativeType

The native type to allocate memory for.

Returns:Pointer

a Pointer instance that can access the memory.

allocateback to summary
public static Pointer allocate(Runtime runtime, Type type)

Allocates a new block of java memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

type:Type

The type to allocate memory for.

Returns:Pointer

a Pointer instance that can access the memory.

allocateback to summary
public static Pointer allocate(Runtime runtime, TypeAlias type)

Allocates a new block of java memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

type:TypeAlias

The type alias to allocate memory for.

Returns:Pointer

a Pointer instance that can access the memory.

allocateDirectback to summary
public static Pointer allocateDirect(Runtime runtime, int size)

Allocates a new block of native memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

size:int

The size in bytes of memory to allocate.

Returns:Pointer

a Pointer instance that can access the memory.

allocateDirectback to summary
public static Pointer allocateDirect(Runtime runtime, long size)

Allocates a new block of native memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

size:long

The size in bytes of memory to allocate.

Returns:Pointer

a Pointer instance that can access the memory.

allocateDirectback to summary
public static Pointer allocateDirect(Runtime runtime, NativeType type)

Allocates a new block of native memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

type:NativeType

The native type to allocate memory for.

Returns:Pointer

a Pointer instance that can access the memory.

allocateDirectback to summary
public static Pointer allocateDirect(Runtime runtime, TypeAlias type)

Allocates a new block of native memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

type:TypeAlias

The type alias to allocate memory for.

Returns:Pointer

a Pointer instance that can access the memory.

allocateDirectback to summary
public static Pointer allocateDirect(Runtime runtime, int size, boolean clear)

Allocates a new block of native memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

size:int

The size in bytes of memory to allocate.

clear:boolean

Whether the memory contents should be cleared, or left as random data.

Returns:Pointer

a Pointer instance that can access the memory.

allocateDirectback to summary
public static Pointer allocateDirect(Runtime runtime, long size, boolean clear)

Allocates a new block of native memory and wraps it in a Pointer accessor.

Parameters
runtime:Runtime

The current runtime.

size:long

The size in bytes of memory to allocate.

clear:boolean

Whether the memory contents should be cleared, or left as random data.

Returns:Pointer

a Pointer instance that can access the memory.

allocateTemporaryback to summary
public static Pointer allocateTemporary(Runtime runtime, NativeType type)

Allocates a new block of transient native memory and wraps it in a Pointer accessor. The memory returned by this method should not be passed to native methods that store the address for later use, as it may change each time it is passed to native code.

Parameters
runtime:Runtime

The current runtime.

type:NativeType

The native type to allocate memory for.

Returns:Pointer

a Pointer instance that can access the memory.

allocateTemporaryback to summary
public static Pointer allocateTemporary(Runtime runtime, TypeAlias type)

Allocates a new block of transient native memory and wraps it in a Pointer accessor. The memory returned by this method should not be passed to native methods that store the address for later use, as it may change each time it is passed to native code.

Parameters
runtime:Runtime

The current runtime.

type:TypeAlias

The type alias to allocate memory for.

Returns:Pointer

a Pointer instance that can access the memory.

allocateTemporaryback to summary
public static Pointer allocateTemporary(Runtime runtime, NativeType type, boolean clear)

Allocates a new block of transient native memory and wraps it in a Pointer accessor. The memory returned by this method should not be passed to native methods that store the address for later use, as it may change each time it is passed to native code.

Parameters
runtime:Runtime

The current runtime.

type:NativeType

The native type to allocate memory for.

clear:boolean

Whether the memory contents should be cleared, or left as random data.

Returns:Pointer

a Pointer instance that can access the memory.