Click or drag to resize

UnmanagedBuffer Class

Represents a buffer of memory stored on the unmanaged (native) heap.
Inheritance Hierarchy
SystemObject
  Ookii.JumboUnmanagedBuffer

Namespace:  Ookii.Jumbo
Assembly:  Ookii.Jumbo (in Ookii.Jumbo.dll) Version: 2.0.0
Syntax
public sealed class UnmanagedBuffer : IDisposable

The UnmanagedBuffer type exposes the following members.

Constructors
  NameDescription
Public methodUnmanagedBuffer(Int32)
Initializes a new instance of the UnmanagedBuffer class.
Public methodUnmanagedBuffer(Int64)
Initializes a new instance of the UnmanagedBuffer class.
Top
Properties
  NameDescription
Public propertyBuffer
Gets a pointer to the first byte of the buffer.
Public propertySize
Gets the size of the buffer.
Top
Methods
  NameDescription
Public methodStatic memberCopy(Byte, Int32, UnmanagedBuffer, Int32, Int32)
Copies data from a managed array to the buffer.
Public methodStatic memberCopy(UnmanagedBuffer, Int32, Byte, Int32, Int32)
Copies data from a buffer to a managed array.
Public methodStatic memberCopyCircular(Byte, Int32, UnmanagedBuffer, Int64, Int32)
Copies data from a managed array to the buffer, wrapping around if necessary.
Public methodStatic memberCopyCircular(UnmanagedBuffer, Int64, Byte, Int32, Int32)
Copies data from a circular buffer to a managed array.
Public methodDispose
Releases all resources used by this class.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Releases all resources used by this class.
(Overrides ObjectFinalize.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodResize
Resizes the buffer.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

This class is used as an alternative for byte[]. The main differences are that the memory is returned to the OS when the class is disposed/finalized, and the buffer is not zero-initialized.

The main reason for the existence of this class is Mono's reluctance to release memory from the managed heap back to the OS which can lead to pagefile thrashing if you're dealing with many large buffers. This problem may not apply to the sgen garbage collector, but this has not been tested.

See Also