This is my part of the code that occurred and segmentation fault:
int main (int argc, char *argv[]) {
printf ("====================================================\n");
double pointArray[MAX_NUM_OF_POINTS][DIMENSION];
double range;
int num_of_nearest;
double queryPoint[DIMENSION];
int counter;
int dist;
int num;
printf ("====================================================\n");
}
where MAX_NUM_OF_POINTS was defined to be 100,000,000.
However, when I changed this number to be smaller like 100,000, the segmentation fault disappeared.
Could anyone tell me the reason?
pointArrayis 800'000'000 bytes for each dimension which is almost 800MB whereas the default stack size on Windows is only 1MB and on Linux is 4/8MB. If DIMENSION is 3 then your array is aready ~2.4GB