The normal use of Heap functions is to use HeapCreate
when your app starts up, and to store the HANDLE
in a global place.
Or just use the process default heap by using GetProcessHeap()
HeapAlloc
and HeapFree
are used to actually allocate and deallocate memory from that heap.
And, finally, assuming you created a heap and arn't using the process heap, HeapDestroy
on app shutdown to delete the whole heap and release any remaining leaked allocations.
As the process heap that exists by default is unlimited, there is no real benefit to creating your own heap over just using the GetProcessHeap
heap.
If you have some specific allocation intensive task, then you could use a user heap configured for no serialization, and/or low fragmentation by overriding new and delete operators for that specific class (rather than generally).
The possibilities are, well, the opposite of endless.