Archived

This topic is now archived and is closed to further replies.

Metal Typhoon

still having problem with memory leaks..

Recommended Posts

Metal Typhoon    122
i can''t do it.. i dont know what''s happenning .. i added these : #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> and before my program ends i added _CrtDumpMemoryLeaks (); it show this : :\program files\microsoft visual studio\vc98\include\crtdbg.h(552) : {125} normal block at 0x0FC00040, 1048576 bytes long. Data: < > 9D 9D 9D 9F A0 A1 A3 A4 A4 A5 A7 A8 A9 A9 AA AB {55} normal block at 0x078E1A00, 512 bytes long. Data: < > 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 c:\program files\microsoft visual studio\vc98\include\crtdbg.h(552) : {43} normal block at 0x078E1D80, 16 bytes long. Data: < F > 98 F3 46 00 01 00 00 00 00 00 00 00 00 00 00 00 c:\program files\microsoft visual studio\vc98\include\crtdbg.h(552) : {42} normal block at 0x078E0030, 33 bytes long. Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD c:\program files\microsoft visual studio\vc98\include\crtdbg.h(552) : {41} normal block at 0x078E1DC0, 40 bytes long. Data: < F > EC F2 46 00 02 00 00 00 00 00 00 but after all i added a breakpoiny at the begging of my prog.. then when it stopes i go to QuickWatc and add this _crtBreakAlloc .. then i change the value from -1 to let''s say 41 ... but it wont go .. what else do i have to do to know where the the leak is happening ?

Share this post


Link to post
Share on other sites
Metal Typhoon    122
quote:
Original post by cnstrnd
using crtdbg with C++ make dumped informations
irrevelant because you use the new operator
witch call inner allocation functions.

to locate witch block you don''t release, try :
MMGR at FluidStudios


ok i got it now.. can u help me to set up ? what to do now ? thx in advance

Share this post


Link to post
Share on other sites
cnstrnd    118
Give this a try: Using the Debug Heap from C++

--

Looking in "crtdbg.h", i found that declaring _CRTDBG_MAP_ALLOC
define inline function to debug version of new operators (causing
the "c:\program files\microsoft visual studio\vc98\include\crtdbg.h(552)" thing).

What i would recommend is to define your own new macro:

// in a header of yours, say "heap.h"
#include <crtdbg.h>
#define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )

Then include "heap.h" in all your source files (I mean .cpp
files). You must take care that your new macro doesn't
propagate to std libs.

// in DoomEngine.cpp
#include <set>
#include <new>
#include "DoomEngine.h"
#include "heap.h"

The main problem is you can't overload new operator in
classes if the new macro is defined.

But you could define new operator in class scope (in header
file) where new macro isn't visible.

This is very experimental to me so if anyone have another
rock solid method, let us know !

[edited by - cnstrnd on January 31, 2003 12:43:05 PM]

Share this post


Link to post
Share on other sites
niyaw    158
quote:
Original post by cnstrnd
using crtdbg with C++ make dumped informations
irrevelant because you use the new operator
witch call inner allocation functions.


no it doesn''t. use _CrtSetBreakAlloc to break on the specific allocation id, which is in the memory leak report.

Share this post


Link to post
Share on other sites
daerid    354
Don''t call _CrtDumpMemoryLeaks yourself.

Call _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);

And it''ll automatically call _CrtDumpMemoryLeaks after the execution of main()

Share this post


Link to post
Share on other sites