protected override void DisposeUnmanaged() { IntPtr ptr = Interlocked.Exchange(ref _pointer, IntPtr.Zero); // If pointer is null, the memory was already freed or never allocated. if (ptr != IntPtr.Zero) { MemoryManagement.Free(ptr); } }
private void FreeMemory() { IntPtr ptr = Interlocked.Exchange(ref _pointer, IntPtr.Zero); // If pointer is null, the memory was already freed or never allocated. if (ptr != IntPtr.Zero) { MemoryManagement.Free(ptr); } }
private void FreeMemory() { IntPtr ptr = Interlocked.Exchange(ref _pointer, IntPtr.Zero); // If pointer is null, the memory was already freed or never allocated. if (ptr != IntPtr.Zero) { if (_usesSharedMemory) { MemoryManagement.UnmapSharedMemory(ptr); if (_sharedMemory != IntPtr.Zero && !_isMirror) { MemoryManagement.DestroySharedMemory(_sharedMemory); _sharedMemory = IntPtr.Zero; } } else { MemoryManagement.Free(ptr); } } }
private void FreeMemory() { IntPtr ptr = Interlocked.Exchange(ref _pointer, IntPtr.Zero); // If pointer is null, the memory was already freed or never allocated. if (ptr != IntPtr.Zero) { if (_usesSharedMemory) { MemoryManagement.UnmapSharedMemory(ptr, Size); } else { MemoryManagement.Free(ptr); } foreach (MemoryBlock viewStorage in _viewStorages.Keys) { viewStorage.DecrementViewCount(); } _viewStorages.Clear(); } }