Debugging a memory leak program with #define _CRTDBG_MAP_ALLOC 
Author Message
 Debugging a memory leak program with #define _CRTDBG_MAP_ALLOC

Hello,
    I am trying to fix a memory leak problem in my program. I followed
the MSDN's technical articles. As suggested, I add the following to my
code:

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
....
_CrtDumpMemoryLeaks();

    However, my program can't be link with the line '#define
_CRTDBG_MAP_ALLOC'. If I exclude it, the program link and run fine
(gives me the memory leak detected messages). The following is the
message:

Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator

Debug/fcconsole.exe : fatal error LNK1169: one or more multiply defined
symbols found
Error executing link.exe.

    How can I solve the linking problem?

    Thanks in advance for your advise!

    Yours,
    Raymond



Wed, 22 May 2002 03:00:00 GMT  
 Debugging a memory leak program with #define _CRTDBG_MAP_ALLOC
Hello,
    I figured out my problem. I have a _findfirst called without invoking
_findclose later. And that caused the memory leak.

    On the other hand, I found that the #define _CRTDBG_MAP_ALLOC caused
the linking error when afxinet.h is included.

    Yours,
    Raymond

Quote:

> Hello,
>     I am trying to fix a memory leak problem in my program. I followed
> the MSDN's technical articles. As suggested, I add the following to my
> code:

> #define _CRTDBG_MAP_ALLOC
> #include <stdlib.h>
> #include <crtdbg.h>
> ....
> _CrtDumpMemoryLeaks();

>     However, my program can't be link with the line '#define
> _CRTDBG_MAP_ALLOC'. If I exclude it, the program link and run fine
> (gives me the memory leak detected messages). The following is the
> message:

> Linking...
> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator

> Debug/fcconsole.exe : fatal error LNK1169: one or more multiply defined
> symbols found
> Error executing link.exe.

>     How can I solve the linking problem?

>     Thanks in advance for your advise!

>     Yours,
>     Raymond



Thu, 23 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. memory leaks and _CRTDBG_MAP_ALLOC

2. BUG: Debug MFC7 not build with _CRTDBG_MAP_ALLOC defined

3. Tracking memory leaks and debugging memory problems

4. Problem with #define _CRTDBG_MAP_ALLOC (VC.NET)

5. #define _CRTDBG_MAP_ALLOC --- not very useful?

6. Debug memory leaks

7. Debugging Memory Leak

8. How do I debug ADO recordset memory leaks

9. Memory Leak Debugging ( and COM )

10. debugging memory leaks

11. Debugging Memory Leaks in CRecordSets

12. Debug memory leak

 

 
Powered by phpBB® Forum Software