主对话框:
m_tab.InsertItem(0, _T("基本设置"));
m_tab.InsertItem(1, _T("高级设置")); //关联框,并把TAB设置为父窗口
————》 m_odlg.Create(IDD_OSET, GetDlgItem(IDC_TAB));
m_addlg.Create(IDD_ADSET, GetDlgItem(IDC_TAB));程序执行到上面是总是异常终止,提示内存泄漏。
The thread 'Win32 Thread' (0x5d8) has exited with code 3 (0x3).
Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {598} normal block at 0x003FD978, 42 bytes long.
Data: < x > 0C 00 E5 78 0C 00 00 00 0C 00 00 00 01 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(195) : {597} normal block at 0x003FD918, 32 bytes long.
Data: < > EB 03 00 00 00 00 00 00 EC 03 00 00 00 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(181) : {596} normal block at 0x003FD8C8, 20 bytes long.
Data: < > FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {583} normal block at 0x003FCDA8, 22 bytes long.
Data: < x > 0C 00 E5 78 02 00 00 00 02 00 00 00 01 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(195) : {582} normal block at 0x003FCD38, 48 bytes long.
Data: < > 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(181) : {581} normal block at 0x003FCCE0, 28 bytes long.
Data: < > FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.
The program '[1080] TestNDA.exe: Native' has exited with code 3 (0x3).
m_tab.InsertItem(0, _T("基本设置"));
m_tab.InsertItem(1, _T("高级设置")); //关联框,并把TAB设置为父窗口
————》 m_odlg.Create(IDD_OSET, GetDlgItem(IDC_TAB));
m_addlg.Create(IDD_ADSET, GetDlgItem(IDC_TAB));程序执行到上面是总是异常终止,提示内存泄漏。
The thread 'Win32 Thread' (0x5d8) has exited with code 3 (0x3).
Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {598} normal block at 0x003FD978, 42 bytes long.
Data: < x > 0C 00 E5 78 0C 00 00 00 0C 00 00 00 01 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(195) : {597} normal block at 0x003FD918, 32 bytes long.
Data: < > EB 03 00 00 00 00 00 00 EC 03 00 00 00 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(181) : {596} normal block at 0x003FD8C8, 20 bytes long.
Data: < > FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141) : {583} normal block at 0x003FCDA8, 22 bytes long.
Data: < x > 0C 00 E5 78 02 00 00 00 02 00 00 00 01 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(195) : {582} normal block at 0x003FCD38, 48 bytes long.
Data: < > 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(181) : {581} normal block at 0x003FCCE0, 28 bytes long.
Data: < > FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.
The program '[1080] TestNDA.exe: Native' has exited with code 3 (0x3).
如果放在Dialog类的OnInitDialog函数中应该没问题吧,帖出的代码不是很详细。
异常终止是会有内存泄漏,主要的问题是为什么异常终止,你可能需要看一下GetDlgItem(IDC_TAB)是不是返回了有效的指针,如果ID不对的话这个函数是会返回NULL的
对于内存泄露找不到地方,你看看是不是有.cpp文件不是vc创建的?这些文件中没有含有如下代码:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
找到这些文件,添加上这些代码,就能找到了!
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif如果不是看看GetDlgItem(IDC_TAB)是不是返回了有效的指针
再检查别的地方有没有用到过new来分配内存,别忘了delete它