mardi 20 novembre 2018

Stcuk with Unhandled exception at 0x00007FF74F27A526 : Stack Overflow

I am having stack overflow related exception. To be clear on that, I have no recursive function that can lead to blowing up stack. Although somewhere in my application I am creating a huge array with std::array and I am using class templates.

I thought of doing allocating memory dynamically but that is the last thing I want to do, also in template function which causing me the problem goes like this:

//class Template
template <class T, int Point, int End>
class Node;
private:
int Point;
int End;
std::array <T, Point*End>;
public:
// Rest of the stuff!
//Operator defined in class
//End of Node object1 is equal to Point of Node object2 always so;

template <int entry>
Node<T,Point,entry> operator* (const Node<T,End,entry> &source)
{
  Node<T,Point,entry> temporary_node(0.);

//for_loop to multiply each element store in std::array

return temporary_node;
}

It is important to mention that my array size is somewhere around 10000000.

  1. What is the solution if I don't want to use dynamic memory allocation:

    • Let's say if I do, then how can I allocate memory dynamically for temporary node in * operator defined above, as it takes up memory for vector when I do this:

      Node temporary_node;

  2. I am on Windows and I also don't want to increase stack size manually as going over 1MB manually will solve the problem but It will be risky and maybe buggy.

Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire