In
computer science dynamic memory allocation is the allocation of memory storage
for use in a computer program during the runtime of that program. It is a way
of distributing ownership of limited memory resources among many pieces of data
and code. A dynamically allocated object remains allocated until it is deallocated
explicitly, either by the programmer or by a garbage collector this is notably
different from automatic and static memory allocation. It is said that such an
object has dynamic lifetime.The problem of fulfilling an allocation request, which
involves finding a block of unused memory of a certain size in the heap, is a
difficult problem. A wide variety of solutions have been proposed, including:
1)Free
lists
2)Paging
3)Buddy memory allocation
The
main problem for most dynamic memory allocation algorithms is to avoid both internal
and external fragmentation while keeping both allocation and deallocation efficient.
Also, most algorithms in use have the problem that a large number of small allocations
can cause wasted space due to collecting metadata; thus most programmers avoid
this, sometimes by using a strategy called chunking.