I'm having a stack overflow problem in my code. I am declaring a few arrays of size 10000 and get a stack overflow error but when I reduce the size to 5000 there is no problem. I understand that getting a stack overflow means either I have too many recursions or the program has exceeded its limit. There are 1000s of lines of code and I don't know how to locate the problem efficiently so I wanted to make sure that my arrays aren't too large. Does anyone know how much memory the program can take up? I have like 50 arrays or so with size 10000.
@ Johnnyboy: Nope, if you run out of RAM the OS caches stuff to disk into what is called the pagefile; and it does this without telling you or your process. A Stack Overflow is usually exactly what it sounds like, the size of something went over the boundry of the Stack.
but doesn't the heap take it from the stack anyway? like if there isn't enough memory overall taking memory and reserving it wouldn't create more memory right?
whereas if I use vectors then I have to traverse the entire code and add in the .at() function to use the vectors elements.
No, you don't. You can access a vector's elements through subscript notation just like you do with arrays. The at() mehod only provides range checking.
When you use ".push_back" with a vector you are using a type of dynamically allocated memory. A "vector" is just a class with tools built up around it to make working with dynamically sized array's MUCH easier. Also you shouldn't be addressing ANY kind of array, dynamic or static, by iterating through it's contents with hard code, that's just weak programming.
"by iterating through it's contents with hard code, that's just weak programming."
Yeah that's not really my style, I didn't want to be bugged for information, I mean to clean it up once I get the simulation working properly for set values.
Also you shouldn't be addressing ANY kind of array, dynamic or static, by iterating through it's contents with hard code, that's just weak programming.