I am working to make a large array of structs in C. I need the array to hold over 1 million struct instances. However when the array size gets above a couple hundred thousand the program crashes. It runs fine for the first bit then it crashes. I am running Windows 7 with 6 gb of RAM.
What is the root cause of this problem? Below is the code
struct Job {
unsigned long id;
unsigned int num_preds;
unsigned int resources;
unsigned int* pred_array;
};
int main()
{
//Counter and loop variables (Do not use for any other purpose)
unsigned int i,j,k,count;
unsigned long height,num_jobs;
// This is our input section
height = 1000;
//Calculate the number of jobs
num_jobs = (height+1)*height*0.5;
printf("%d \n",num_jobs);
struct Job jobs[num_jobs];
return 0;
}