big arrays = segmentation fault

hello everybody
this a simple conceptual question, i guess.

i have created a class, called Section.
and i created a bidimensional array of objects of that class:
Section sections[70][66];
if i change it to [70][67], i get a segmentation fault error. is it because the program tries to alocate memory that it's not avaliable?
but when i run my program, the task manager says that my program is using only~60mb from RAM, and mor than halfis still avaliable. i can open other programs, such as chromium, etc.

any idea why does this happen?
thanks in advance!
I may be wrong here. However I'd usually expect a segmentation fault to be caused by accessing some memory area outside of that which is 'owned' by your program. Typically it might be caused a subscript out of range. If that's the case, it's not really related to the size of the array, but rather to the way in which it is later used (or misused).

One thing which raises alarm bells for me is the use of numeric literals such as 67 or 70 as hard-coded values.
Section sections[70][66];

I'd prefer to do
const int rows = 70;
const int cols = 66;
Section sections[rows][cols];

Because that way, anywhere in the program such as a for-loop where a subscript must be within the array bounds, it can be checked against rows or cols. The big advantage comes when you want to change the size of the array, you just change the value in one place and the entire program still retains its integrity.
ah, my favorite kind of overflow...
oops! it actually seems to be more related to something i found on the page ne555 posted:
'Very large stack variables'

if i do it with vectors, instead of arrays (as i'm always a bit unsure on how to use dynamic arrays correctly) the issue doesn't happens.

anyway, i'm not hard-coding values like that. i was just for a matter of readability. i have learned that (from your responses to other topics, btw :P )

thanks for the help!
Topic archived. No new replies allowed.