Static memory allocation
From Wikipedia, the free encyclopedia
Static memory allocation refers to the process of allocating memory at compile-time before the associated program is executed, unlike dynamic memory allocation or automatic memory allocation where memory is allocated as required at run-time.
An application of this technique involves a program module (e.g. function or subroutine) declaring static data locally, such that this data is inaccessible in other modules unless references to it are passed as parameters or returned. A single copy of static data is retained and accessible through many calls to the function in which it is declared. Static memory allocation therefore has the advantage of modularising data within a program design in the situation where this data must be retained through the runtime of the program.
The use of static variables within a class in object oriented programming enables a single copy of such data to be shared between all the objects of that class.