mardi 24 mai 2016

large arrays, std::vector and stack overflow

I have a program that is reading data from large arrays, I initially divided the program in two separate projects in Visual Studio and each one separately worked fine, but when I tried to put them together the program acted funny skipping some steps while debugging. I'm very new on C++ so I started doing some research and I found that maybe I was filling the stack with those huge arrays and that I should try to put them on the heap instead.

I decided to change each of the arrays for a std::vector and initialize them this way

std::vector<double> meanTimeAO = { 0.4437, 0.441, 0.44206, 0.44632, 0.4508, 0.45425,...}

but after changing all of the arrays now when I try to compile the compiler crashes with a stack overflow, I thought I was liberating memory space from the stack by changing the arrays as a vector but it seems I had the opposite results, why is that??

and how should I deal with these big arrays? 9they are fixed never changing values or size)

Thank you in advance!!

Aucun commentaire:

Enregistrer un commentaire