Click or drag to resize

IJVMWrapperDirectNewDirectBuffer(IntPtr, Int64, EventHandlerObject, Object, Int32) Method

Creates a new https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html in the JVM which belongs to rawAddr.

Namespace: MASES.JCOBridge.C2JBridge.JVMInterop
Assembly: C2JBridge (in C2JBridge.dll) Version: 2.5.12.240512-4d4b2fafd3df13602ccdeccef07b026ccf8b47b0
Syntax
JCOBridgeDirectBuffer<byte> NewDirectBuffer(
	IntPtr rawAddr,
	long capacity,
	EventHandler<Object> disposeEvent = null,
	Object disposeEventState = null,
	int timeToLive = -1
)

Parameters

rawAddr  IntPtr
The pointer where data is stored
capacity  Int64
Declares the memory available, in Byte, associated to rawAddr
disposeEvent  EventHandlerObject  (Optional)
An optional EventHandlerTEventArgs can be used to be informed when the rawAddr can be safely retired becuase the JVM is no moore using the pointer of rawAddr.
disposeEventState  Object  (Optional)
The data will be associated to disposeEvent, by default the value will be rawAddr
timeToLive  Int32  (Optional)
The time to live, expressed in milliseconds, the underlying memory shall remain available; if the time to live expires the memory is retired leaving potentially the JVM under the possibility of an access violation.

Return Value

JCOBridgeDirectBufferByte
A new instance of JCOBridgeDirectBufferT holding the memory of rawAddr shared with the https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html
Remarks
The memory associated to rawAddr shall be available until the JVM reference of the newly created https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html is garbage collected to avoid access violation within the JVM. Under heavy pressure the memory footprint can raise up and generate an OutOfMemoryException, use the functionality with caution or take into account the timeToLive option which can help to recover the memory in advance before the Garbage Collector of the JVM retires the https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html If the user of JCOBridgeDirectBufferT is pretty sure that the memory is no more needed from the JVM, e.g. the invoked method does not queue the https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html and its lifetime ends when the method returns, invoke Dispose to immediately release unmanaged resources and free the memory
See Also