none
Memory leak detection

    Pertanyaan

  • This link provides info about how to detect memory leak, http://msdn.microsoft.com/en-us/library/x98tx3cf(v=VS.100).aspx.

    I followed the link. I'm using VS2010. I've few queries:-

    1. In this article, it mentioned 2 ways to have the reports showed with detailed info against 'new' operator.

    • one is to use the following,
    • #ifdef _DEBUG
      #ifndef DBG_NEW
      #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
      #define new DBG_NEW
      #endif
      #endif // _DEBUG
    • Another is to use '#define _CRTDBG_MAP_ALLOC_NEW'.

    If I used 1st approach (w/ DBG_NEW), I got various compile error in crtdbg.h, e.g. C2365: 'operator new': redefinition; previous definition was 'function' @ line 1163..

    If I used 2nd approach (_CRTDBG_MAP_ALLOC_NEW), I got the source path, however, all paths pointed to crtdbg.h. Is this expected?

    Which approach should I use for new/delete in VS2010?

    Thanks.


    • Diedit oleh Wood-MSDN 12 Oktober 2011 22:31
    12 Oktober 2011 21:42

Jawaban

Semua Balasan