I'd like to use an array (very large) of pointer in a class:
char* myClass::_myArray[1200000]; // 1.2 million elements
If I new it in my constructor:
myClass::myClass()
{
for (int n = 0; n < 1200000; n++)
{
_myArray[n] = new char[32];
}
}
then in my destructor, I dispose it:
myClass::~myClass()
{
for (int n = 0; n < 1200000; n++)
{
if (NULL != _myArray[n])
{
delete[] _myArray[n]; // exception throws here
_myArray[n] = NULL;
}
}
}
it always throw exception like following picture:

I have no idea why. I am wondering if I would like to pre-allocate a buffer for the class object until it quits, how should I do this? This buffer should work like a global variable, that can be used any time the function/methods within the class is called.
Thanks a lot. Appreciate any opinion and education.
Additional information:
I set the array size 1000 (char* myClass::_myArray[1000]; ), it works fine. When I set it to 5000, it throws exception like this after the app exit. When it is 1.2 million, the exception throws when app starts.
the delete[] _myArray[n] is where the exception happens, but it happens at random n number.