public FrozenSegment GetSegment() { if (_allocated == IntPtr.Zero) { throw new Exception("Segment already built"); } nint size = (nint)(_allocated.ToInt64() - _buffer.ToInt64()); _allocated = IntPtr.Zero; IntPtr segment = GCHelpers.RegisterFrozenSegment(_buffer, size); return(new FrozenSegment(segment, _buffer)); }
public void Release() { GCHelpers.UnregisterFrozenSegment(this.underlyingSegment); Marshal.FreeHGlobal(this.underlyingBuffer); }