请教一个关于内存泄漏的问题。
提示: 作者被禁止或删除 内容自动屏蔽
// 内存泄露.cpp : Defines the entry point for the console application. // #include "stdafx.h" // test3.cpp : Defines the entry point for the console application. #include <stdio.h> #include <iostream> //#include <process.h> using namespace std; inline void EnableMemLeakCheck() { _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); } void test(double* X) { X[0]=1; double* x=new double[300]; delete [] x; } int main() { EnableMemLeakCheck(); _CrtMemState s1, s2; _CrtMemCheckpoint( &s1 ); _CrtMemDumpStatistics( &s1 ); double* xkoll=new double[3]; for (int ii = 0; ii<1000; ii++) { test(&xkoll[0]); } _CrtMemCheckpoint( &s2 ); _CrtMemDumpStatistics( &s2 ); delete[] xkoll; //这里少了[],而且我认为这个语句应该移动到这里比较好 system("pause"); return 0; }