Hello. I try to catch bad_alloc error (if "new" cannot allocate some memory) but program always shut down with "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information".
With other IDE everything ok.
Can you tell me, what flag or something else i need to use for stable processing "bad_alloc" without shot down program.
#include <cstdlib>
#include <iostream>
#include <new>
using namespace std;
struct T
{
float Mas[0xFFFFFF];
};
void OutMem()
{
cout<<"MemOut\n";
throw(bad_alloc());
}
int main(int argc, char *argv[])
{
set_new_handler(OutMem);
try
{
T *Arr = new T[0xFFFFFF];
}
catch(bad_alloc& e)
{
cout<<"ERROR\n";
}
system("PAUSE");
return EXIT_SUCCESS;
}
PS. sorry for my english
PPS windows7 x64