// vc6 cl /MDd /Zi testMemLeakage.cpp memory_leak.cpp // /Zi to include debug information (source level debugging) // /MDd use libcd.lib (crtdbg) // vc10 cl /MTd /Zi testMemLeakage1a.cpp memory_leak.cpp #include "memory_leak.h" #include #include //#include struct File { char *name; char *data; }; void foo() { struct File *filePtr; filePtr = (struct File *) malloc(sizeof(struct File)); filePtr->name = (char *) malloc(200*sizeof(char)); filePtr->data = (char *) malloc(5000*sizeof(char)); printf("%p %p %p\n", filePtr, filePtr->name, filePtr->data); // do something free(filePtr); } void main() { set_initial_leak_test(); int i; for (i=0; i<10; i++) foo(); // system("pause"); // the memory dump would occur after the pause }