Home / Questions / What is static memory allocation?
Explanatory Question

What is static memory allocation?

👁 1,040 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

  • In case of static memory allocation, memory is allocated at compile time, and memory can't be increased while executing the program. It is used in the array.
  • The lifetime of a variable in static memory is the lifetime of a program.
  • The static memory is allocated using static keyword.
  • The static memory is implemented using stacks or heap.
  • The pointer is required to access the variable present in the static memory.
  • The static memory is faster than dynamic memory.
  • In static memory, more memory space is required to store the variable.

For example:  
int a[10];  

The above example creates an array of integer type, and the size of an array is fixed, i.e., 10.