internal void Release() { if (buffer != IntPtr.Zero) { allocatedMemory -= bufferSizeInBytes; MemoryNativeApi.ReleaseMemoryObject(buffer); buffer = IntPtr.Zero; } }
/// <summary> /// Disposes of the resources that have been acquired by the memory object. /// </summary> /// <param name="disposing">Determines whether managed object or managed and unmanaged resources should be disposed of.</param> public override void Dispose() { // Checks if the memory object has already been disposed of, if not, then the memory object is disposed of if (!IsDisposed) { MemoryNativeApi.ReleaseMemoryObject(Handle); } // Makes sure that the base class can execute its dispose logic base.Dispose(); }
/// <summary> /// Disposes of the resources that have been acquired by the memory object. /// </summary> /// <param name="disposing">Determines whether managed object or managed and unmanaged resources should be disposed of.</param> protected override void Dispose(bool disposing) { // Checks if the memory object has already been disposed of, if not, then the memory object is disposed of if (!this.IsDisposed) { MemoryNativeApi.ReleaseMemoryObject(this.Handle); } // Makes sure that the base class can execute its dispose logic base.Dispose(disposing); }