This topic has not yet been rated - Rate this topic

CoTaskMemFree function

Applies to: desktop apps | Metro style apps

Frees a block of task memory previously allocated through a call to the CoTaskMemAlloc or CoTaskMemRealloc function.

Syntax

void CoTaskMemFree(
  __in_opt  LPVOID pv
);

Parameters

pv [in, optional]

A pointer to the memory block to be freed. If this parameter is NULL, the function has no effect.

Return value

This function does not return a value.

Remarks

The CoTaskMemFree function uses the default OLE allocator.

The number of bytes freed equals the number of bytes that were originally allocated or reallocated. After the call, the memory block pointed to by pv is invalid and can no longer be used.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Objbase.h

Library

Ole32.lib

DLL

Ole32.dll

See also

CoTaskMemAlloc
CoTaskMemRealloc
IMalloc::Free

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Why P/Invoke?
Why bother with those P/Invoke methods when you can just call Marshal.FreeCoTaskMem?
C# syntax
[DllImport("ole32.dll")]
public static extern void CoTaskMemFree(IntPtr ptr);
vb.net syntax
<DllImport("ole32.dll")> _
Public Shared Sub CoTaskMemFree(ByVal ptr As IntPtr)
End Sub