Christina Daniel
Christina Daniel

Reputation: 169

What is the max size for an array of complex doubles?

In C++, what is the maximum size of a one dimensional array of complex doubles (i.e. std::complex<double> array[dimension])? Is there a difference to the max size if I declare the array in main versus globally?

Upvotes: 2

Views: 709

Answers (1)

eerorika
eerorika

Reputation: 238351

The maximum size of the array will be M / sizeof(std::complex<double>) bytes where M is the remaining free memory in bytes. Amount of free memory is affected by how much total memory there is, and by how much memory is used for other purposes.

If you declare the array as an automatic variable, then it will have automatic storage. The amount of automatic storage is limited on most systems. Typical total automatic storage shared by all automatic variables is one or few megabytes.

Upvotes: 2

Related Questions