下面这个程序在vc10编译release版,运行结果是弹筐unhandled win32 exception.
我想既然CreateMemoryResourceNotification函数有通知的作用,那么进程是不能能否捕获这个消息并处理呢? 我的程序应该怎么改才能捕获并处理这个消息?谢谢!void WINAPI f(LPVOID){
while(true)int*p=new int[50000];
}
int main(void){
HANDLE hMem=CreateMemoryResourceNotification(LowMemoryResourceNotification);
HANDLE hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)f,NULL,0,NULL);
if(INVALID_HANDLE_VALUE==hThread){
return 1;
}
HANDLE h[2]={hMem,hThread};
WaitForSingleObject(hThread,INFINITE);
while(true){
DWORD dwWait=WaitForMultipleObjects(2,h,TRUE,INFINITE);
if(dwWait==WAIT_OBJECT_0+1){
printf("low mem\n");
}
}
return 0;
}
我想既然CreateMemoryResourceNotification函数有通知的作用,那么进程是不能能否捕获这个消息并处理呢? 我的程序应该怎么改才能捕获并处理这个消息?谢谢!void WINAPI f(LPVOID){
while(true)int*p=new int[50000];
}
int main(void){
HANDLE hMem=CreateMemoryResourceNotification(LowMemoryResourceNotification);
HANDLE hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)f,NULL,0,NULL);
if(INVALID_HANDLE_VALUE==hThread){
return 1;
}
HANDLE h[2]={hMem,hThread};
WaitForSingleObject(hThread,INFINITE);
while(true){
DWORD dwWait=WaitForMultipleObjects(2,h,TRUE,INFINITE);
if(dwWait==WAIT_OBJECT_0+1){
printf("low mem\n");
}
}
return 0;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货