Game sometimes crashes when closing or process stay in memory
My problem is that sometimes, when closing the game, one of two may occur:
I'm not sure if those two are related or completely independent issues. Both of those happen very rarely, but I have to eliminate these situations.
As for the crash, I made a dump and it says that the crash occurs in PeekMessage() function. The code looks like this:
bool running = true;
/// Reset timer
Timer.Reset();
MSG msg;
ZeroMemory(&msg, sizeof(msg));
/// message pump
while(running)
{
int msg_count = 10;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) && msg_count-->0)
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
if (msg.message == WM_QUIT)
{
running = false;
break;
}
}
if (ApplicationActive)
{
PrepareFrame();
RenderFrame();
}
else
Sleep(1);
Sleep(1);
}
From what I see it, the message handling routine is handling at most 10 messages per loop iteration. Is it possible the crash is the result of overflowing message queue? And process staying in memory is the result of "not reaching" quit message because it's too far in the queue? If it helps, here's the call stack from dump:
ntdll.dll!_KiFastSystemCallRet@0()
ntdll.dll!_ZwWaitForSingleObject@12() + 0xc bytes
ntdll.dll!_RtlpWaitOnCriticalSection@8() + 0xc8 bytes
ntdll.dll!_RtlEnterCriticalSection@4() - 0x4b84 bytes
ntdll.dll!_LdrLockLoaderLock@12() + 0x6b bytes
ntdll.dll!_LdrLoadDll@16() + 0xd8 bytes
kernel32.dll!_LoadLibraryExW@12() + 0xf7 bytes
user32.dll!___ClientLoadLibrary@4() + 0x60 bytes
ntdll.dll!_KiUserCallbackDispatcher@12() + 0x2e bytes
user32.dll!_NtUserPeekMessage@20() + 0xc bytes
user32.dll!__PeekMessage@24() + 0x2d bytes
user32.dll!_PeekMessageA@20() + 0x572 bytes
SchoolBus.exe!VCasualApp::Run() Line 229 + 0x12 bytes C++ SchoolBus.exe!wWinMain(HINSTANCE__ * formal=0x00400000, HINSTANCE * formal=0x00400000, HINSTANCE * formal=0x00400000, HINSTANCE * formal=0x00400000) Line 61 C++ SchoolBus.exe!__tmainCRTStartup() Line 578 + 0x1c bytes C kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll! RtlUserThreadStart@8() + 0x27 bytes
ntdll.dll!_RtlUserThreadStart@8() + 0x1b bytes
上一篇: 在winhttp.dll中访问冲突
下一篇: 关闭或进程停留在内存时,游戏有时会崩溃