Different between static and dynamic memory allocation
Answers
1.In this case, variables get allocated permanently
2.Allocation is done before program execution
3.It uses the data structure called stack for implementing static allocation
4.Less efficient
5.There is no memory reusability.
Dynamic Memory allocation.
1.In this case, variables get allocated only if your program unit gets active
2.Allocation is done during program execution
3.It uses the data structure called heap for implementing dynamic allocation
4.More efficient
5.There is memory reusability and memory can be freed when not required
thanks
hope it helps u
☺
Good Luck To U ....
Answer:
Its not that static memory allocation is not used but its has many disadvantages or we can call them limitations :
The scope and lifetime is limited
Only when globally defined its scope is not bounded
The amount of memory available through stack-based allocation is commonly far less than the amount of memory available through heap-based memory allocation.
Once you move out of the system,the memory crashes that is a very big disadvantage.
Merits :
It has automatic cleanup and no manual assistance is required for this process.It is best used when the size is already know to you.
Dynamic Memory Allocation:
Its is performed during run time and is assigned to heap.The size may or may not be known in starting.There is no particular order of assignment.