 | IJVMWrapperDirectRentT Method |
Namespace: MASES.JCOBridge.C2JBridge.JVMInteropAssembly: C2JBridge (in C2JBridge.dll) Version: 2.6.9.260611-9a148513a79c26cdd7f1dde468f4f9e06ef3bc7e
SyntaxJCOBridgeSharedBufferStream<T> Rent<T>(
long capacity = -1
)
where T : struct, new()
Function Rent(Of T As {Structure, New}) (
Optional capacity As Long = -1
) As JCOBridgeSharedBufferStream(Of T)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
JCOBridgeSharedBufferStreamTA pooled instance of
JCOBridgeSharedBufferStreamT ready to be written via Stream-based APIs and then passed to
NewDirectBufferT(JCOBridgeSharedBufferStreamT).
Exceptions
Remarks
See Also