C++ – data area

c++memorystaticstorage

In C++ the storage class specifier static allocates memory from the data area. What does "data area" mean?

Best Solution

In addition to what Konrad said, declaring a variable as static basically means that the memory for it gets allocated with the program as it is loaded, as opposed to on the heap or the stack. Historically, using only static variables in a critical applications meant that the memory footprint of the application would not change at run-time and hence it was less likely to fail due to resource limitations. Don't know if this is still true of modern operating systems.

If you get your compiler to generate a mapfile as part of its output, you can have a look see at what is in all the various sections, including data.