2D std::array , stack overflow exception

0

I am having speed issues with the C++ standard arrays , so I am testing using the stl::array for computation, to see how fast it is.

I define a two dimensional array of the struct PAPoint (see below) and attempt to create a 2D array of it. It compiles ok, but when I try to run I get a Stack overflow (literally) exception. 2D arrays with size 200x200 run ok but not 500x500. Is there a solution? Is the stack really that small?

Thank you

#include <iostream>
#include <array>
#include <cmath>

#define PAWIDTH 500 //STACK OVERFLOW FOR LARGE NUMBERS
#define PAHEIGHT 500

struct PApoint{
    float elpotential = 0;
    bool iselectrode = false;
}
;

int main()
{
    std::cout << "SpeedTestEMLaplaceSolver.cpp using 2D std::array of PApoint\n";
    std::array< std::array<PApoint, PAWIDTH>, PAHEIGHT> myPAArray; //Array is allocated in the stack so large arrays can trigger stack overflow
    //Gives error in chkstk.asm
    /*
    Unhandled exception at 0x00827659 in SpeedTestEMLaplaceSolver.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00402000). occurred
    */
}
c++
arrays
visual-studio
stl
asked on Stack Overflow Oct 17, 2020 by Luis

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0