Property CapacityLong
CapacityLong
Gets or sets the number of bytes allocated for this stream as a long integer.
public virtual long CapacityLong { get; set; }
Property Value
- long
The length of the usable portion of the buffer for the stream as a long integer.
Remarks
The logical capacity may exceed MaxValue on supported configurations (typically 64-bit processes with sufficient memory). When the current capacity is larger than MaxValue, read it through the CapacityLong property (or other long-based APIs). The Capacity property getter throws InvalidOperationException in that situation because it must return an int.
Assigning a new capacity requires a value greater than or equal to Length and less than or equal to this instance's KZDev.PerfUtils.MemoryStreamSlim.MaximumCapacity, which is fixed for the lifetime of the instance based on how the stream was constructed.
For dynamically growing streams, the configured per-instance maximum does not exceed GlobalMaximumCapacity at creation time. Streams created over an existing byte array buffer operate in fixed-buffer mode and may impose a lower effective ceiling that matches the wrapped MemoryStream backing store.
Hard upper bounds also depend on process bitness and reported available memory; the implementation rejects capacities beyond what the runtime can represent or safely support for in-memory streams.
Exceptions
- ArgumentOutOfRangeException
The capacity is set to a value less than zero or greater than KZDev.PerfUtils.MemoryStreamSlim.MaximumCapacity.