Rediger

Del via


Marshal.FreeCoTaskMem(IntPtr) Method

Definition

Frees a block of memory allocated by the unmanaged COM task memory allocator.

public:
 static void FreeCoTaskMem(IntPtr ptr);
[System.Security.SecurityCritical]
public static void FreeCoTaskMem (IntPtr ptr);
public static void FreeCoTaskMem (IntPtr ptr);
[<System.Security.SecurityCritical>]
static member FreeCoTaskMem : nativeint -> unit
static member FreeCoTaskMem : nativeint -> unit
Public Shared Sub FreeCoTaskMem (ptr As IntPtr)

Parameters

ptr
IntPtr

nativeint

The address of the memory to be freed.

Attributes

Remarks

You can use FreeCoTaskMem to free any memory allocated by AllocCoTaskMem, ReAllocCoTaskMem, or any equivalent unmanaged method. If the ptr parameter is IntPtr.Zero, the method does nothing.

FreeCoTaskMem exposes the COM CoTaskMemFree function, which frees all bytes so that you can no longer use the memory that the ptr parameter points to.

In addition to FreeCoTaskMem, the Marshal class provides two other memory-deallocation methods: DestroyStructure and FreeHGlobal.

Applies to

See also