Static memory allocation is an allocation technique which allocates a fixed amount of memory during compile time and the operating system internally uses a data structure known as Stack to manage this.
Background
Memory is central to any computing system and its architecture determines the performance of any process. While building system, one of the fundamental task is to allocate memory.
There are two types of memory allocated to a program:
Stack memory
Heap memory
Stack memory is allocated during compilation time execution. This is known as static memory allocation.
Whereas, heap memory is allocated at run-time compilation. This is know as dynamic memory allocation.
Static memory allocation
In Static Memory Allocation the memory for your data is allocated when the program starts. The size is fixed when the program is created. It applies to global variables, file scope variables, and variables qualified with static defined inside functions. This memory allocation is fixed and cannot be changed, i.e. increased or decreased after allocation. So, exact memory requirements must be known in advance.
Key features:
Variables get allocated permanently
Allocation is done before program execution
It uses the data structure called stack for implementing static allocation
Less efficient
There is no memory reusability