Handling Insufficient Memory Conditions
Testing for failed memory allocation can be done with code such as the following:
using namespace std;
#define BIG_NUMBER 100000000
int *pI = new int[BIG_NUMBER];
if( pI == 0x0 )
cout << "Insufficient memory" << endl;
}There is another ways to handle failed memory allocation requests: write a custom recovery routine to handle such a failure, then register your function by calling the _set_new_handler run-time function.