<p>Is global memory initialized in C++? And if so, how?</p>

<p>(Second) clarification:</p>

<p>When a program starts up, what is in the memory space which will become global memory, prior to primitives being initialized? I'm trying to understand if it is zeroed out, or garbage for example.</p>

<p>The situation is: can a singleton reference be set - via an <code>instance()</code> call, prior to its initialization:</p>

<pre><code>MySingleton* MySingleton::_instance = NULL;
</code></pre>

<p>and get two singleton instances as a result?</p>

<p>See my C++ quiz on on multiple instances of a singleton...</p>

Yes global primitives are initialized to NULL.
Example:
```
```
int x;

int main(int argc, char**argv)
{
  assert(x == 0);
  int y;
  //assert(y == 0); <-- wrong can't assume this.
}
```
```
You cannot make any assumptions about classes, structs, arrays, blocks of memory on the heap...
It's safest just to always initialize everything.