【发布时间】:2012-05-11 04:26:22
【问题描述】:
这里是一些示例代码:
#include <crtdbg.h>
#include <windows.h>
#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif
int main()
{
int* arr = new int[10];
delete arr; //not using delete [] arr
_CrtMemDumpAllObjectsSince(NULL); // dumping leak logs
return 0;
}
如您所见,我没有使用delete [] arr,但仍然没有任何泄漏。
谁能更正它并解释为什么_CrtMemDumpAllObjectsSince() 没有在上面的代码中倾倒泄漏。
【问题讨论】:
标签: c++ arrays memory-leaks delete-operator