In the video it’s told that there are two parts of memory static and heap memory. Is this static part same as the stack memory?
Also can you please elaborate on this static part of the memory…
Doubt with a concept in the video
yes, static memory is managed by stack as opposed to heap that is used in dynamic memory allocation
these are some contrast between the two type of allocations
1 In the static memory allocation(SMA) , variables get allocated permanently. In the Dynamics memory allocation (DMA), variables get allocated only if your program unit gets active.
2 Static Memory Allocation is done before program execution. Dynamics Memory Allocation is done during program execution.
3 SMA uses stack for managing the static allocation of memory DMA uses heap for managing the dynamic allocation of memory
4 SMA is less efficient while DMA is more efficient
5 In Static Memory Allocation, there is no memory re-usability In Dynamics Memory Allocation, there is memory re-usability and memory can be freed when not required
6 In static memory allocation, once the memory is allocated, the memory size can not change. In dynamic memory allocation, when memory is allocated the memory size can be changed.
7 In Static memory allocation scheme, we cannot reuse the unused memory. This allows reusing the memory. In DMA the user can allocate more memory when required. Also, the user can release the memory when the user needs it.
8 In SMA scheme, execution is faster than dynamic memory allocation. In DMA scheme, execution is slower than static memory allocation.
9 In SMA memory is allocated at compile time. while in DMA memory is allocated at run time.
10 In SMA memory remains from start to end of the program. In DMA allocated memory can be released at any time during the program.
11 Example: This static memory allocation is generally used for array and dynamic memory allocation is generally used for linked list.