HeapDestroy function (heapapi.h)

Destroys the specified heap object.

HeapDestroy de-commits and releases all the pages of a private heap object, and it invalidates the handle to the heap.


BOOL HeapDestroy(
  [in] HANDLE hHeap


[in] hHeap

A handle to the heap to be destroyed. This handle is returned by the HeapCreate function. Do not use the handle to the process heap returned by the GetProcessHeap function.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.


Processes can call HeapDestroy without first calling the HeapFree function to free memory allocated from the heap.


Enumerating a Heap


Requirement Value
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header heapapi.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

Heap Functions


Memory Management Functions

Vertdll APIs available in VBS enclaves