Memory Leak ???
-
Hi I have some problem when run this program (press F5) when I click Run button then close program in suddenly. When return to VC++ it tells Detect Memory leak !!! and dump object ... I don't understand how it occur ??? and What is it ??? My program want Stop button that terminate running job not terminate program. Thanks bool stop; void CPumpMessageView::OnRun() // clicked Run Button { stop=false; for(int i=0; i<100; i++) { PumpMessage(); if(stop) break; else Sleep(250); } } void CPumpMessageView::PumpMessage() { MSG msg ; while (PeekMessage (&msg, 0, 0, 0, PM_NOREMOVE)) { if (!(AfxGetApp()->PumpMessage())) { // regenerate WM_QUIT for main message loop. ::PostQuitMessage(0); break; } } // let MFC do its idle processing LONG lIdle = 0; while (AfxGetApp()->OnIdle(lIdle++)); } void CPumpMessageView::OnStop() // clicked Stop Button { stop=true; }
-
Hi I have some problem when run this program (press F5) when I click Run button then close program in suddenly. When return to VC++ it tells Detect Memory leak !!! and dump object ... I don't understand how it occur ??? and What is it ??? My program want Stop button that terminate running job not terminate program. Thanks bool stop; void CPumpMessageView::OnRun() // clicked Run Button { stop=false; for(int i=0; i<100; i++) { PumpMessage(); if(stop) break; else Sleep(250); } } void CPumpMessageView::PumpMessage() { MSG msg ; while (PeekMessage (&msg, 0, 0, 0, PM_NOREMOVE)) { if (!(AfxGetApp()->PumpMessage())) { // regenerate WM_QUIT for main message loop. ::PostQuitMessage(0); break; } } // let MFC do its idle processing LONG lIdle = 0; while (AfxGetApp()->OnIdle(lIdle++)); } void CPumpMessageView::OnStop() // clicked Stop Button { stop=true; }
The problem does not seem to be with this code. If you dynamically created an object of type CPumpMessageView make sure you destroy the object before the application object terminates. If this is not your problem please post the object dump so that I can better understand the problem.