I have some code here where there is an array of "Bacon" objects. I can compile and run it and add objects to the array, but when I make the array size more than one million, I run it and it says 'bacon.exe has stopped working' and I have to close it. I think it might be a memory leak, but I am still learning about that. I am using netbeans ide, and I tried allocating more memory when it gets compiled, but I couldn't figure out how to do that. Note: It isn't because my whole computer runs out of memory, because I still have 2GB free after running the program. Here is my code:
#include <iostream>
#include "Bacon.h"
using namespace std;
int main() {
const int objs = 1000000;
Bacon *bacs[objs];
for(int i = 0;i < objs;i++){
bacs[i] = new Bacon(2,3);
}
for(int i = 0;i < objs;i++){
bacs[i]->print();
}
cin.ignore();
return 0;
}