Table of Contents

Class DisposableObject

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Represents a class which manages its own memory.

public abstract class DisposableObject : IDisposable
Inheritance
DisposableObject
Implements
Derived
Inherited Members

Constructors

DisposableObject()

Default constructor

protected DisposableObject()

DisposableObject(bool)

Constructor

protected DisposableObject(bool isEnabledDispose)

Parameters

isEnabledDispose bool

true if you permit disposing this class by GC

Properties

AllocatedMemory

Gets or sets a memory address allocated by AllocMemory.

protected nint AllocatedMemory { get; set; }

Property Value

nint

AllocatedMemorySize

Gets or sets the byte length of the allocated memory

protected long AllocatedMemorySize { get; set; }

Property Value

long

DataHandle

Gets or sets a handle which allocates using cvSetData.

protected GCHandle DataHandle { get; }

Property Value

GCHandle

IsDisposed

Gets a value indicating whether this instance has been disposed.

public bool IsDisposed { get; protected set; }

Property Value

bool

IsEnabledDispose

Gets or sets a value indicating whether you permit disposing this instance.

public bool IsEnabledDispose { get; set; }

Property Value

bool

Methods

AllocGCHandle(object)

Pins the object to be allocated by cvSetData.

protected GCHandle AllocGCHandle(object obj)

Parameters

obj object

Returns

GCHandle

AllocMemory(int)

Allocates the specified size of memory.

protected nint AllocMemory(int size)

Parameters

size int

Returns

nint

Dispose()

Releases the resources

public void Dispose()

Dispose(bool)

Releases the resources

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and unmanaged resources can be disposed. If false, the method has been called by the runtime from inside the finalizer and you should not reference other objects. Only unmanaged resources can be disposed.

DisposeManaged()

Releases managed resources

protected virtual void DisposeManaged()

DisposeUnmanaged()

Releases unmanaged resources

protected virtual void DisposeUnmanaged()

~DisposableObject()

Destructor

protected ~DisposableObject()

NotifyMemoryPressure(long)

Notifies the allocated size of memory.

protected void NotifyMemoryPressure(long size)

Parameters

size long

ThrowIfDisposed()

If this object is disposed, then ObjectDisposedException is thrown.

public void ThrowIfDisposed()