What Is Heap Memory?
Heap memory is a common pool of free memory used for dynamic memory allocations within an application. Dynamic memory allocation is the allocation of memory (or storage) for use during the runtime of an application. Memory that is dynamically allocated must be explicitly allocated and deallocated by the application. The term heap memory is used because most implementations for dynamic memory allocation make use of a binary tree data structure called a heap. There are two primary operations performed on a heap. The first operation is allocation. This operation reserves a block of storage of a given size and returns a pointer to the reserved block. Exclusive ownership of the block of storage is given to the application; the application can use the block of storage for whatever purpose it requires. The second operation is deallocation. This operation returns a given block of storage (previously allocated by the application) to the heap. When a block of storage is deallocated, ownership of