Dynamic memory is allocated on heap. De-allocation is counterpart of the
allocation operation. the task of allocation and De-allocation is handled by the
base/standard libraries. These store information about the allocated memory like
base address and size. initially all of heap is free.
Many implementations are possible. e.g the free space may be maintained in a
free list and the the allocated memory in a doubly linked list or hash table.
Memory can only be requested to be de-allocated with the same address which
was returned during the allocation.
Fragmentation of the free space is a known problem. a request for allocation
may fail even when there is enough memory available in the heap. it may be due
to the non-availability of a contiguous chunk of memory at least equal to the
size of the requested size.
Automatic heap management strategy e.g. garbage collection alleviate some of
the problems with better utilization of the heap memory.