本人建了一个多文档MFC,运行时不能正常关闭子窗口,后来调试发现时dbgheap.c line 1044错误。
打开dbgheap.c文件定位到1044行:
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
查了一下是指针重复释放问题。
这个时候注意检查一下自己程序代码的类的构造函数与析构函数代码。无参构造函数对应空的析构函数,拷贝构造函数对应自添加清空函数的析构函数。
另外当程序中new动态分配空间,用完后一定要delete掉。基本上就是这类问题