Where does the m_pMainWnd delete?
-
I have a client system, to create a CMainFrame object, but I am afraid that there will be memory leak about CMainFrame object.After step in, I cannot find where the m_pMainWnd pointer is deleted. Will I delete this pointer in the function ExitInstance()? :-D
BOOL CApp::InitInstance()
{
CMainFrame* pMainFrame = new CMainFrame();
if (!pMainFrame) return FALSE;
pMainFrame->LoadFrame(IDR_MAINFRAME,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
NULL);
m_pMainWnd = pMainFrame;
m_pMainWnd->UpdateWindow();
return TRUE;
}int CApp::ExitInstance()
{
return CWinApp::ExitInstance();
} -
I have a client system, to create a CMainFrame object, but I am afraid that there will be memory leak about CMainFrame object.After step in, I cannot find where the m_pMainWnd pointer is deleted. Will I delete this pointer in the function ExitInstance()? :-D
BOOL CApp::InitInstance()
{
CMainFrame* pMainFrame = new CMainFrame();
if (!pMainFrame) return FALSE;
pMainFrame->LoadFrame(IDR_MAINFRAME,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
NULL);
m_pMainWnd = pMainFrame;
m_pMainWnd->UpdateWindow();
return TRUE;
}int CApp::ExitInstance()
{
return CWinApp::ExitInstance();
}yu-jian wrote:
After step in, I cannot find where the m_pMainWnd pointer is deleted.
It's handled automatically by the framework.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
yu-jian wrote:
After step in, I cannot find where the m_pMainWnd pointer is deleted.
It's handled automatically by the framework.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Oh, sorry, I do not use the .net. This is the unmanaged C++. I cannot see where the system delete this pointer in file appcore.cpp. :)
yu-jian wrote:
Oh, sorry, I do not use the .net.
What does that have to do with anything?
yu-jian wrote:
This is the unmanaged C++.
If you mean this is the unmanaged C++ forum, of course it is. Did something indicate otherwise?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Oh, sorry, I do not use the .net. This is the unmanaged C++. I cannot see where the system delete this pointer in file appcore.cpp. :)
It is is deleted inside
CFrameWnd::PostNcDestroy()
(see winfrm.cpp) which is called byCWnd::OnNcDestroy
which is the last member function called when the Windows window is destroyed.