Click or drag to resize

IJVMWrapperDirectNewDirectBufferT(JCOBridgeSharedBufferStreamT) Method

Creates a new https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html in the JVM which shares the memory of stream. This is the preferred overload for high-rate scenarios as it avoids repeated array copies from CLR to JVM and benefits from pooled buffer management.

Namespace: MASES.JCOBridge.C2JBridge.JVMInterop
Assembly: C2JBridge (in C2JBridge.dll) Version: 2.6.9.260611-9a148513a79c26cdd7f1dde468f4f9e06ef3bc7e
Syntax
JCOBridgeDirectBuffer<T> NewDirectBuffer<T>(
	JCOBridgeSharedBufferStream<T> stream
)
where T : struct, new()

Parameters

stream  JCOBridgeSharedBufferStreamT
A JCOBridgeSharedBufferStreamT obtained from RentT(Int64) and populated via Stream-based APIs, to be used directly within the JVM from a https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html.

Type Parameters

T
The native type of the resulting JCOBridgeDirectBufferT

Return Value

JCOBridgeDirectBufferT
A new instance of JCOBridgeDirectBufferT holding the memory of stream shared with the https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html.
Exceptions
ExceptionCondition
ArgumentExceptionThrown when stream was not obtained through RentT(Int64).
NotSupportedExceptionThrown when the JVM is unable to generate a https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html instance.
Remarks
The memory associated to stream will be retained until the JVM reference of the newly created https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html is garbage collected. Under heavy pressure the memory footprint can raise up and generate an OutOfMemoryException; use the functionality with caution.

Lifecycle management: the subsystem automatically returns stream to the internal pool once the JVM Garbage Collector retires the associated https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html, i.e. when the https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html has been fully consumed by the JVM. A direct call to Dispose on the returned JCOBridgeDirectBufferT is therefore a no-op; do not attempt to manually dispose stream after passing it to this method.

Pool strategy: the HPA (High Performance Application) runtime variant draws stream instances from a highly optimized pool tuned for high-throughput workloads, while the standard runtime variant uses a lighter pool. In both cases the pooling is fully transparent to the caller.

See Also