Hi,
I want to make a BIG array with about 10M elements, but it seems like I'm overflowing the stack, if I do an array of 500 000 elements its ok, but when I go to 5 000 000 I get segmentation fault.
basically this is all I do:
Code:#define SAMPLES 5000000; int main(void) { struct block_data bd[SAMPLES]; }
the I save a lot of data in bd, but the seg fault comes before that. tried valgrind and it points to where I initialize variables the lines under I defined bd, so I think I'm overflowing the stack ... i've also try to allocate memory like this:
but still segementationfault.Code:struct block_data *bd[SAMPLES]; uint64_t i = 0; while(i<SAMPLES) { bd[i] = (struct block_data *)malloc(sizeof(struct block_data)); ++i; }
So how can I do this?