Heaps are used for arbitrary list structures, complex data organizations. Don't know when employees will join and leave the company, must be able to keep track of all them using the least possible amount of storage. In stack allocation, all the holes are together in one big chunk. Refer to Knuth volume 1 for detailed treatment of what follows. Typically, heap allocation schemes use a free list to keep track of the storage that is not in use.
Algorithms differ in how they manage the free list.
During release operations, merge adjacent free blocks. Also merge on releases. Most first fit implementations are rotating first fit. Best fit is not necessarily better than first fit. Suppose memory contains 2 free blocks of size 20 and 15.