I have played around with try and catch(std::bad_alloc &errH) blocks and that seemed to prevent the crash.
I tried using
Code:
int x(999999), y(999999);
int nBytes(x*y);
which yielded a large number. But when I used
Code:
int x(1<<16), y(1<<16);
int nBytes(x*y);
I found that x*y was 0! So
Code:
array = new double[0];
is what caused the crash. I solved it by using
Code:
int x(1<<16), y(1<<16);
int64 nBytes = static_cast<int64>(x)*y;
Now I realize that allocating 32GB of memory won't crash the system, only create a very big page file. Not at the point of allocation of course but when filling it with data.
I also realize that 'nBytes' is not the number of bytes but number of elements in this context.