Static memory is allocated by the language compiler when it translates source code so the scope is controlled by the rules of the compiler. For example, in the C language, extern variables can be accessed anywhere, and static variables can be referenced within the source module or routine, depending on where they are declared. Note that the static memory described in this section is not the same as the C language static storage class; static memory refers to any variable that is permanently allocated at a particular address for the life of the program.
Static memory is appropriate when you know that only one instance of an object exists throughout the application. For example, if you want to keep a list of active contexts or a mutex to control some shared resource, you would not want individual threads to have their own copies of that data.
The scope of static memory depends on language scoping rules. The lifetime is the life of the program.