Click or drag to resize

IJVMWrapperDirectRentT Method

Returns a JCOBridgeSharedBufferStreamT with an initial capacity derived from capacity, to be populated via Stream-based APIs and then passed to NewDirectBufferT(JCOBridgeSharedBufferStreamT).

Namespace: MASES.JCOBridge.C2JBridge.JVMInterop
Assembly: C2JBridge (in C2JBridge.dll) Version: 2.6.9.260611-9a148513a79c26cdd7f1dde468f4f9e06ef3bc7e
Syntax
JCOBridgeSharedBufferStream<T> Rent<T>(
	long capacity = -1
)
where T : struct, new()

Parameters

capacity  Int64  (Optional)
The plausible number of elements of T type to be written into the stream; the byte size is computed as capacity * sizeof(T). The default value of -1 instructs the subsystem to allocate the minimum meaningful unit, which corresponds to one system memory page (see SystemPageSize). Regardless of the value provided, the effective allocation is always rounded up to the nearest multiple of the system page size, since the underlying native allocator operates at page granularity. Passing a value smaller than one page therefore has no practical advantage over using the default. This value is a hint, not a hard limit: if the actual data written exceeds the initial allocation, the underlying buffer will grow automatically via reallocation. However, providing a value greater than or equal to the actual data size is strongly recommended to avoid reallocation overhead, especially in high-rate scenarios. Callers that process data of a known or predictable size are encouraged to implement their own estimation strategy — for example, tracking the stable size observed in previous invocations — so that the initial capacity converges toward the real value over time and reallocations become increasingly rare or disappear entirely.

Type Parameters

T
The Type to be used: it can be any Byte, Int16, Int32, Int64, Single, Double or a type defined as a struct.

Return Value

JCOBridgeSharedBufferStreamT
A pooled instance of JCOBridgeSharedBufferStreamT ready to be written via Stream-based APIs and then passed to NewDirectBufferT(JCOBridgeSharedBufferStreamT).
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionThrown when capacity is zero or any positive value that, once multiplied by sizeof(T), overflows a Int64.
Remarks
The returned JCOBridgeSharedBufferStreamT is drawn from an internal pool. The HPA (High Performance Application) runtime variant uses a highly optimized pool tuned for high-throughput scenarios, while the standard runtime variant uses a lighter pool suitable for moderate workloads. The instance must not be manually disposed; its lifecycle is fully managed by the subsystem and it is automatically returned to the pool once the JVM Garbage Collector retires the associated https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html created by NewDirectBufferT(JCOBridgeSharedBufferStreamT).
See Also