Flagrant
09/03/2007, 13:53
merhaba, bu memory leaks olayi nedir acaba?
bunu gormemiz icin programin basina asagidaki gibi bir kod eklememiz gerekiyormus. Nedir ne ise yarar asagidaki kodu yorumlayabilecek olan var mi? tesekkurler.
#inlcude "stdafx.h"
...
...
int main()
{
//**Enable memory leak dumping at the end of the program
//** required include files are included in the given stdafx files
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
//uncomment this next line if you want to see memory leaks reported
//#define WANT_TO_SEE_MEMORY_LEAKS
#ifdef WANT_TO_SEE_MEMORY_LEAKS
int * ptr = new int[5]; //lets get 5 int-block from the heap and not return
*ptr = 5;
ptr++; //first cell of the block has value 5
*ptr = 6; //second cell has value 6
ptr++;
*ptr++=7;
*ptr++=8;
*ptr++=9; //last cell has value 9
#endif
...
...
}
bunu gormemiz icin programin basina asagidaki gibi bir kod eklememiz gerekiyormus. Nedir ne ise yarar asagidaki kodu yorumlayabilecek olan var mi? tesekkurler.
#inlcude "stdafx.h"
...
...
int main()
{
//**Enable memory leak dumping at the end of the program
//** required include files are included in the given stdafx files
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
//uncomment this next line if you want to see memory leaks reported
//#define WANT_TO_SEE_MEMORY_LEAKS
#ifdef WANT_TO_SEE_MEMORY_LEAKS
int * ptr = new int[5]; //lets get 5 int-block from the heap and not return
*ptr = 5;
ptr++; //first cell of the block has value 5
*ptr = 6; //second cell has value 6
ptr++;
*ptr++=7;
*ptr++=8;
*ptr++=9; //last cell has value 9
#endif
...
...
}