/// <summary> /// Frees a block of memory previous allocated with AllocateLarge(). /// </summary> /// <param name="block">The block to free.</param> /// <param name="bytes">The size of the block.</param> public static void FreeLarge(IntPtr block, ulong bytes) { bool result = SafeNativeMethods.VirtualFree(block, UIntPtr.Zero, NativeConstants.MEM_RELEASE); if (!result) { int error = Marshal.GetLastWin32Error(); throw new InvalidOperationException("VirtualFree returned an error: " + error.ToString(CultureInfo.InvariantCulture)); } if (bytes > 0) { MemoryPressureManager.RemoveMemoryPressure((long)bytes); } }