부족한 메모리 조건 처리
다음과 같이 실패한 메모리 할당에 대한 테스트를 수행할 수 있습니다.
// insufficient_memory_conditions.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
#define BIG_NUMBER 100000000
int main() {
int *pI = new int[BIG_NUMBER];
if( pI == 0x0 ) {
cout << "Insufficient memory" << endl;
return -1;
}
}
실패한 메모리 할당 요청을 처리하는 또 다른 방법은, 이러한 오류를 처리하는 사용자 지정 복구 루틴을 작성한 후, _set_new_handler 런타임 함수를 요청하여 함수를 등록하는 것입니다.