Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        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);
                }
            }
        }
Beispiel #4
0
        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();
            }
        }