Marshal.FreeCoTaskMem(IntPtr) Marshal.FreeCoTaskMem(IntPtr) Marshal.FreeCoTaskMem(IntPtr) 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);
static member FreeCoTaskMem : nativeint -> unit
Public Shared Sub FreeCoTaskMem (ptr As IntPtr)

Parameters

ptr
IntPtr IntPtr IntPtr IntPtr

The address of the memory to be freed.

Remarks

You can use FreeCoTaskMem to free any memory allocated by AllocCoTaskMem, ReAllocCoTaskMem, or any equivalent unmanaged method. If the ptr parameter is null, 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.

Security

SecurityCriticalAttribute
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Applies to

See also