Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function attempts to compact a specified heap by coalescing adjacent free blocks of memory and decommitting large free blocks of memory.

Syntax

UINT HeapCompact(
  HANDLE 
hHeap,
  DWORD 
dwFlags
);

Parameters

hHeap

[in] Handle to the heap to be compacted.

This parameter is a handle returned by the HeapCreateor GetProcessHeapfunction.

dwFlags

[in] Heap access options. The possible value, HEAP_NO_SERIALIZE, is ignored. The heap is always serialized.

Return Value

The size of the largest committed free block in the heap, in bytes, indicates success. Zero indicates failure. To get extended error information, call GetLastError.

In the unlikely case that there is no space available in the heap, the function return value is zero, and GetLastErrorreturns the value NO_ERROR.

Remarks

There is no guarantee that an application can successfully allocate a memory block of the size returned by HeapCompact. Other threads or the commit threshold might prevent such an allocation.

Requirements

Header winbase.h
Library coredll.lib
Windows Embedded CE Windows CE 5.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also