A
Archana
Hi all,
I am new to c++. I have written one c++ application. I want to detect
memory leaks from my program.
I tried with following code which i got from net.
if(_CrtDumpMemoryLeaks() == TRUE) // reports no leak
{
printf("detected 1");
}
int *foo = new int[4];
if(_CrtDumpMemoryLeaks() == TRUE)//reports a memory leak
{
printf("detected 2");
}
delete[] foo;
foo = NULL;
if(_CrtDumpMemoryLeaks() == TRUE)// reports no leak
{
printf("detected 3");
}
Ideally first time i should not get any memory leak. But when i run
above code all print statements are executed.
Can anyone tell me why this is happening?
Please correct me if i am wrong.
thanks in advance.
I am new to c++. I have written one c++ application. I want to detect
memory leaks from my program.
I tried with following code which i got from net.
if(_CrtDumpMemoryLeaks() == TRUE) // reports no leak
{
printf("detected 1");
}
int *foo = new int[4];
if(_CrtDumpMemoryLeaks() == TRUE)//reports a memory leak
{
printf("detected 2");
}
delete[] foo;
foo = NULL;
if(_CrtDumpMemoryLeaks() == TRUE)// reports no leak
{
printf("detected 3");
}
Ideally first time i should not get any memory leak. But when i run
above code all print statements are executed.
Can anyone tell me why this is happening?
Please correct me if i am wrong.
thanks in advance.