Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
 public void Release()
 {
     GCHelpers.UnregisterFrozenSegment(this.underlyingSegment);
     Marshal.FreeHGlobal(this.underlyingBuffer);
 }