Binarysharp.MemoryManagement.Memory.RemoteAllocation.Dispose C# (CSharp) Method

Dispose() public method

Releases all resources used by the RemoteAllocation object.
Don't use the IDisposable pattern because the class is sealed.
public Dispose ( ) : void
return void
        public virtual void Dispose()
        {
            if (!IsDisposed)
            {
                // Set the flag to true
                IsDisposed = true;
                // Release the allocated memory
                Release();
                // Remove this object from the collection of allocated memory
                MemorySharp.Memory.Deallocate(this);
                // Remove the pointer
                BaseAddress = IntPtr.Zero;
                // Avoid the finalizer
                GC.SuppressFinalize(this);
            }
        }

Usage Example

Esempio n. 1
0
 /// <summary>
 /// Deallocates a region of memory previously allocated within the virtual address space of the remote process.
 /// </summary>
 /// <param name="allocation">The allocated memory to release.</param>
 public void Deallocate(RemoteAllocation allocation)
 {
     // Dispose the element
     if(!allocation.IsDisposed)
         allocation.Dispose();
     // Remove the element from the allocated memory list
     if (InternalRemoteAllocations.Contains(allocation))
         InternalRemoteAllocations.Remove(allocation);
 }
All Usage Examples Of Binarysharp.MemoryManagement.Memory.RemoteAllocation::Dispose