Show / Hide Table of Contents

Class UnmanagedMemoryHandle

Represents managed wrapper of the unmanaged memory.

Inheritance
Object
UnmanagedMemoryHandle
UnmanagedMemory
UnmanagedMemory<T>
Implements
ICloneable
IEquatable<UnmanagedMemoryHandle>
IUnmanagedMemory
IDisposable
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.Unsafe.dll
Syntax
public abstract class UnmanagedMemoryHandle : SafeHandle, ICloneable, IEquatable<UnmanagedMemoryHandle>, IUnmanagedMemory, IDisposable
Remarks

The allocated unmanaged memory is not controlled by GC. However, the unmanaged memory will be released automatically if GC collects the instance of this type.

Properties

| Improve this Doc View Source

Bytes

Gets a span of bytes from the current instance.

Declaration
public Span<byte> Bytes { get; }
Property Value
Type Description
Span<Byte>
| Improve this Doc View Source

IsInvalid

Indicates that this object is no longer valid.

Declaration
public override sealed bool IsInvalid { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

Pointer

Gets a pointer to the allocated unmanaged memory.

Declaration
public Pointer<byte> Pointer { get; }
Property Value
Type Description
Pointer<Byte>
| Improve this Doc View Source

Size

Gets size of allocated unmanaged memory, in bytes.

Declaration
public abstract long Size { get; }
Property Value
Type Description
Int64

Methods

| Improve this Doc View Source

AsStream()

Represents unmanaged memory as stream.

Declaration
public Stream AsStream()
Returns
Type Description
Stream

The stream of unmanaged memory.

| Improve this Doc View Source

BitwiseCompare(UnmanagedMemoryHandle)

Bitwise comparison of the memory blocks.

Declaration
public int BitwiseCompare(UnmanagedMemoryHandle other)
Parameters
Type Name Description
UnmanagedMemoryHandle other

The block of memory to be compared.

Returns
Type Description
Int32

Comparison result which has the semantics as return type of .

| Improve this Doc View Source

BitwiseEquals(UnmanagedMemoryHandle)

Computes bitwise equality between two blocks of memory.

Declaration
public bool BitwiseEquals(UnmanagedMemoryHandle other)
Parameters
Type Name Description
UnmanagedMemoryHandle other

The block of memory to be compared.

Returns
Type Description
Boolean

true, if both memory blocks have the same bytes; otherwise, false.

| Improve this Doc View Source

Clear()

Sets all bits of allocated memory to zero.

Declaration
public void Clear()
| Improve this Doc View Source

Equals(UnmanagedMemoryHandle)

Determines whether the given handle points to the same unmanaged memory as this handle.

Declaration
public bool Equals(UnmanagedMemoryHandle other)
Parameters
Type Name Description
UnmanagedMemoryHandle other

The handle to be compared.

Returns
Type Description
Boolean

true, if the given handle points to the same unmanaged memory as this handle; otherwise, false.

| Improve this Doc View Source

Equals(Object)

Determines whether the given handle points to the same unmanaged memory as this handle.

Declaration
public override bool Equals(object other)
Parameters
Type Name Description
Object other

The handle to be compared.

Returns
Type Description
Boolean

true, if the given handle points to the same unmanaged memory as this handle; otherwise, false.

| Improve this Doc View Source

GetHashCode()

Returns hash code of the memory address.

Declaration
public override int GetHashCode()
Returns
Type Description
Int32

The hash code of the memory address.

| Improve this Doc View Source

ReadFrom(Pointer<Byte>)

Copies bytes from the source memory to the memory identified by this object.

Declaration
public void ReadFrom(Pointer<byte> source)
Parameters
Type Name Description
Pointer<Byte> source

The pointer to the source unmanaged memory.

| Improve this Doc View Source

ReadFrom(Stream)

Copies bytes from the specified source stream into unmanaged memory.

Declaration
public long ReadFrom(Stream source)
Parameters
Type Name Description
Stream source

The readable stream.

Returns
Type Description
Int64

The actual number of copied elements.

| Improve this Doc View Source

ReadFromAsync(Stream)

Copies bytes from the given stream to the memory location identified by this object asynchronously.

Declaration
public Task<long> ReadFromAsync(Stream source)
Parameters
Type Name Description
Stream source

The source stream.

Returns
Type Description
Task<Int64>
| Improve this Doc View Source

ReleaseHandle()

Releases unmanaged memory.

Declaration
protected override sealed bool ReleaseHandle()
Returns
Type Description
Boolean

true if unmanaged memory is released successfully; otherwise, false.

| Improve this Doc View Source

ToByteArray()

Creates a copy of unmanaged memory inside of managed heap.

Declaration
public byte[] ToByteArray()
Returns
Type Description
Byte[]

A copy of unmanaged memory in the form of byte array.

| Improve this Doc View Source

ToString()

Returns address of this memory in hexadecimal format.

Declaration
public override string ToString()
Returns
Type Description
String

The address of this memory.

| Improve this Doc View Source

WriteTo(Pointer<Byte>)

Copies elements from the current memory location to the specified memory location.

Declaration
public void WriteTo(Pointer<byte> destination)
Parameters
Type Name Description
Pointer<Byte> destination

The target memory location.

| Improve this Doc View Source

WriteTo(UnmanagedMemoryHandle)

Copies bytes from the current memory location to the specified memory location.

Declaration
public long WriteTo(UnmanagedMemoryHandle destination)
Parameters
Type Name Description
UnmanagedMemoryHandle destination

The target memory location.

Returns
Type Description
Int64

The actual number of copied bytes.

| Improve this Doc View Source

WriteTo(Stream)

Copies bytes from the memory location to the stream.

Declaration
public void WriteTo(Stream destination)
Parameters
Type Name Description
Stream destination

The destination stream.

| Improve this Doc View Source

WriteToAsync(Stream)

Copies bytes from the memory location to the stream asynchronously.

Declaration
public Task WriteToAsync(Stream destination)
Parameters
Type Name Description
Stream destination

The destination stream.

Returns
Type Description
Task

The task instance representing asynchronous state of the copying process.

Operators

| Improve this Doc View Source

Equality(UnmanagedMemoryHandle, UnmanagedMemoryHandle)

Determines whether two handles point to the same unmanaged memory.

Declaration
public static bool operator ==(UnmanagedMemoryHandle first, UnmanagedMemoryHandle second)
Parameters
Type Name Description
UnmanagedMemoryHandle first

The first unmanaged memory handle.

UnmanagedMemoryHandle second

The second unmanaged memory handle.

Returns
Type Description
Boolean

true, if both handles point to the same unmanaged memory; otherwise, false.

| Improve this Doc View Source

Inequality(UnmanagedMemoryHandle, UnmanagedMemoryHandle)

Determines whether two handles point to the the different blocks of unmanaged memory.

Declaration
public static bool operator !=(UnmanagedMemoryHandle first, UnmanagedMemoryHandle second)
Parameters
Type Name Description
UnmanagedMemoryHandle first

The first unmanaged memory handle.

UnmanagedMemoryHandle second

The second unmanaged memory handle.

Returns
Type Description
Boolean

true, if both handles point to the different blocks of unmanaged memory; otherwise, false.

Implements

ICloneable
IEquatable<>
IUnmanagedMemory
IDisposable

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
ExpressionBuilder.Const<T>(T)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX