Every process in Windows NT has one heap called the
default heap. Processes can also have as many other dynamic heaps as they wish, simply by creating and destroying them on the fly. The Win32 subsystem uses the default heap for all global and local memory management functions, and the C run-time library uses the default heap for supporting
malloc functions. The heap memory functions, which indicate a specific heap by its handle, use dynamic heaps. The behavior of dynamic heaps is discussed in the "Win32 Heap Memory API" section later in this article.
The default and dynamic heaps are basically the same thing, but the default heap has the special characteristic of being identifiable as the default. This is how the C run-time library and the Win32 subsystem identify which heap to allocate from. The
GetProcessHeap function returns a handle to the default heap for a process. Since functions such as
GlobalAlloc or
malloc are executed within the context of the thread that called them, they can simply call
GetProcessHeap to retrieve a handle to the default heap, and then manage memory accordingly.