Computer Science, asked by ravimunivenkttappa, 5 months ago

Diffrentate static memory & dynamic memory​

Answers

Answered by jaya9908
1

Answer:

Static memory: Allocation is done before program execution.

Dynamic memory: Allocation is done during program execution.

Explanation:

In static memory allocation, once memory is allocated,memory size can't be changed.

In dynamic memory allocation,memory allocated can be changed at any time.

Answered by pratyush15899
9

Explanation:

Static memory :

Static Memory is allocated for declared variables by the compiler. The address can be found using the address of operator and can be assigned to a pointer. The memory is allocated during compile time.

  1.  In the static memory allocation, variables get allocated permanently
  2. Memory Allocation is done before program execution.
  3. It uses stack for managing the static allocation of memory
  4. It is less efficient
  5. In Static Memory Allocation, there is no memory re-usability.
  6. In static memory allocation, once the memory is allocated, the memory size can not change.

Dynamic memory:

Memory allocation done at the time of execution(run time) is known as dynamic memory allocation. Functions calloc() and malloc() support allocating dynamic memory. In the Dynamic allocation of memory space is allocated by using these functions when the value is returned by functions and assigned to pointer variables. 

  1. In the Dynamic memory allocation, variables get allocated only if your program unit gets active.
  2. Dynamic Memory Allocation is done during program execution.
  3. It uses heap for managing the dynamic allocation of memory
  4. It is more efficient
  5. In Dynamic Memory Allocation, there is memory re-usability and memory can be freed when not required.
  6. In dynamic memory allocation, when memory is allocated the memory size can be changed.

:))

Similar questions