Windows Mobile 6.5
A version of this page is also available for

This function validates the specified heap. HeapValidate scans all the memory blocks in the heap and verifies that the heap control structures maintained by the heap manager are in a consistent state. The HeapValidate function can also be used to validate a single memory block within a specified heap without checking the validity of the entire heap.

BOOL HeapValidate(
  HANDLE hHeap,
  DWORD dwFlags,
  LPCVOID lpMem 


[in] Handle to the heap to be validated.

This parameter is a handle returned by the HeapCreate or GetProcessHeap function.


[in] Heap access options.

HEAP_NO_SERIALIZE is ignored. The heap is always serialized.


[in] Valid pointer to a memory block within the specified heap. This parameter may be NULL.

If this parameter is NULL, the function attemptions to validate the entire heap specified by hHeap.

If this parameter is not NULL, the function attempts to validate the memory block pointed to by lpMem. It does not attempt to validate the rest of the heap.

Nonzero indicates that the specified heap or memory block is valid. Zero indicates that the specified heap or memory block is invalid. On a system set up for debugging, the HeapValidate function displays debugging messages that describe the part of the heap or memory block that is invalid, and stops at a hard-coded breakpoint so that you can examine the system to determine the source of the invalidity. The HeapValidate function does not set the thread's last error value.

There are heap control structures for each memory block in a heap and for the heap as a whole. When you use the HeapValidate function to validate a complete heap, it checks all of these control structures for consistency.

When you use HeapValidate to validate a single memory block within a heap, it checks only the control structures pertaining to that element. HeapValidate can only validate allocated memory blocks. Calling HeapValidate on a freed memory block returns FALSE because there are no control structures to validate.

Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions