Memoryleaks detecting, Probleme
-
Hallo!
Ich benutze Visual Studio 6.0 und programmiere zur Zeit in einer WIN API Anwendung (kein MFC!!) ein DX Game. Ich würde gerne meine Memoryleaks herausfinden und schreibe dazu das in meine main.cpp:#define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h>Dann bei EndGame(), also die Funktion in der ich den Speicher aufräumen will schreibe ich unten:
_CrtDumpMemoryLeaks();Leider bekomme ich als Output nur:
Detected memory leaks! Dumping objects -> d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5841} normal block at 0x04FFAF50, 156 bytes long. Data: < z= > 00 CD CD CD 00 00 00 00 00 00 00 00 7A 3D AE BD d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5840} normal block at 0x04FF90A0, 4 bytes long. Data: < > 18 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5839} normal block at 0x04FF90D0, 4 bytes long. Data: < > 00 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5838} normal block at 0x04FF9100, 4 bytes long. Data: < > 00 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5837} normal block at 0x04FF9130, 4 bytes long. Data: <$ > 24 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5836} normal block at 0x04FF8030, 4 bytes long. Data: < > 00 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5835} normal block at 0x04FF8060, 68 bytes long. Data: < L? L? L? ?> CD CC 4C 3F CD CC 4C 3F CD CC 4C 3F 00 00 80 3F d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5834} normal block at 0x04FF80D0, 1 bytes long. Data: < > 0D d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5833} normal block at 0x04FF9160, 768 bytes long. Data: <)\ 33S> > 29 5C DF BD 33 33 53 3E F0 A7 A6 BD 00 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5832} normal block at 0x04FF8100, 72 bytes long. Data: < > 00 00 02 00 01 00 01 00 02 00 03 00 04 00 06 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {5831} normal block at 0x04FF9490, 864 bytes long. Data: < q} ff ? > 00 00 00 00 71 7D A3 C0 66 66 9A 3F A0 9A C2 C0 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {327} normal block at 0x00AA1A10, 156 bytes long. Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 E0 A0 C3 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {326} normal block at 0x02245028, 4056 bytes long. Data: < > 18 00 00 00 18 00 00 00 18 00 00 00 18 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {325} normal block at 0x0221FF80, 4056 bytes long. Data: < 0 H > 00 00 00 00 18 00 00 00 30 00 00 00 48 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {324} normal block at 0x0221EF68, 4056 bytes long. Data: < $ H l > 00 00 00 00 24 00 00 00 48 00 00 00 6C 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {323} normal block at 0x0221DF50, 4056 bytes long. Data: <$ $ $ $ > 24 00 00 00 24 00 00 00 24 00 00 00 24 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {50} normal block at 0x0221CF38, 4056 bytes long. Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {49} normal block at 0x0220C1A0, 68952 bytes long. Data: <F ?F ?F ? ?> 46 94 16 3F 46 94 16 3F 46 94 16 3F 00 00 80 3F d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {48} normal block at 0x00A951F0, 1095 bytes long. Data: < > 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {47} normal block at 0x022D0040, 1465344 bytes long. Data: < 3 > z > DA CE E9 C0 33 C4 F1 3E AC 1C 7A C0 00 00 00 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {46} normal block at 0x021D0068, 246000 bytes long. Data: < > 00 00 02 00 01 00 00 00 03 00 02 00 04 00 06 00 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {45} normal block at 0x02030040, 1648512 bytes long. Data: < 3 > z > 00 00 00 00 DA CE E9 C0 33 C4 F1 3E AC 1C 7A C0 d:\programme\microsoft visual studio\vc98\include\crtdbg.h(552) : {39} normal block at 0x00AA1D80, 296 bytes long. Data: < - |0 > 8C 8F 17 00 1C 2D 18 00 7C 30 18 00 00 80 00 00 Object dump complete. Thread 0x560 wurde mit Code 0 (0x0) beendet. Thread 0x5AC wurde mit Code 0 (0x0) beendet. Thread 0x4BC wurde mit Code 0 (0x0) beendet. Thread 0x3CC wurde mit Code 0 (0x0) beendet.Wie ihr seht, bekomme ich als Datei nur die crtdbg.h!! Nicht wo das Leak in meinem eigenen Code ist, WIESO?
Danke für die Hilfe
Kevin
-
Weil das Feature, was du vermisst eine Eigenschaft von DEBUG_NEW ist. Und das gibt es glaubich nur bei der MFC - keine Ahnung, ob man es nachbauen kann.
-
und wie finde ich nun wo das Memory leak liegt?
Kevin
-
folgendes:
wenn ich mit malloc Speicher anfordere, wird die richtige Zeile angezeigt, bei new allerdings nicht!
Wieso?
Danke
Kevin
-
hi!
schau dir mal den artikel an!http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvc60/html/memleaks.asp
-
da steht leider nichts zu new / delete
was ich tun kann, damit das richtig angezeigt wird
-
du kannst aber mit
_crtBreakAlloc = XXX;
an der betroffenen stelle einen breakpoint setzen und so auch herausfinden, wo noch ein leak ist
-
hi!
hab mich nochmal schlau gemacht:
du musst afxwin.h einbinden und dann kannst du per
#define new DEBUG_NEW
die memoryleaks auch bei new finden
-
huhu!
Das reicht leider nicht weil jetzt new mehrfrach definiert ist...#ifndef reicht ebenfalls nicht
-
versuche es mal so:
#ifdef new
#undef new
#define new DEBUG_NEW
-
hab ich schon, reicht auch nicht

-
mh doch jetzt geht es, nur leider wird mir jetzt nicht die Codedatei (z.b. main.cpp) angezeigt, das Output ist als hätte ich nicht _CRTDBG_MAP_ALLOC defined!
