“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”
- Static memory allocation utilizes stack which is a limited resource, especially in such environments as kernel mode.
- In the most cases it’s quicker but it also depends in the environment (is stack growth is involved).
- You can’t share the resource allocated on stack in multi-threaded environment.
Static Advantages:
- The advantage is that you don’t need to take care about deallocation.
Dynamic Disadvantages:
- Allocation is slower than static.
- You need to take care about deallocation.
Dynamic Advantages:
- You can share dynamically allocated memory between threads, does not consume stack space.
- You can allocate different types of memory (usualy).
using malloc, calloc and realloc.
disadvantage is run-time overhead and complexity in implementing it…
Dynanic memory needs to be carefully deleted after use.
They are created in distributed area of memory segment.
Disadvantages
1. Dynamic memory allocation is slower than static memory allocation, because dynamic memory allocation happens in heap area.
2. Dynamic memory allocation causes contention between threads, so it degrades performance when it happens in a thread.
Static memory allocation provides speed at the cost of flexibility compared to dynamic memory allocation.
In static memory allocation memory is assigned during compilation time.
In dynamic memory allocation memory is assigned during run time.
static memory allocation use less memory incontrast to DMA
DMA used for best utilization of memory
both have their own ad & disad
Static Disadvantages:
- Static memory allocation utilizes stack which is a limited resource, especially in such environments as kernel mode.
- In the most cases it’s quicker but it also depends in the environment (is stack growth is involved).
- You can’t share the resource allocated on stack in multi-threaded environment.
Static Advantages:
- The advantage is that you don’t need to take care about deallocation.
Dynamic Disadvantages:
- Allocation is slower than static.
- You need to take care about deallocation.
Dynamic Advantages:
- You can share dynamically allocated memory between threads, does not consume stack space.
- You can allocate different types of memory (usualy).
Leave an Answer/Comment