Need Memory Leak Detection with filename

Hi All,

I am actually trying to integrate the Chromium Embedded Framework(ver 3), and the JUCE Library…

At Some Point, i am able to see few memory leaks… I tried Debugging it, but it was of no help. :frowning:

Then in order to know the in detailed description of the Leak(with filename and number) i used(found on some site)

#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>

But this is conflicting with the HeapBlock(as it has its own definitions of malloc, calloc, etc…)

So All i Want to know if it is possible to know the filename and line number of the memory leak(some kind of macro definition i need to put in, as an extension to that of the ones already define in JUCE API), or any other way through which i can get to know the filename and line number…

On Windows we use Visual Leak Detector (http://vld.codeplex.com/) along Juce without problem

I brought this up and Jules position is that why should he have to rename his function names just because Visual Studio decided to make them macros? Anyway, this code snippet might work for you…no guarantees though:

// If the MSVC debug heap headers were included, disable
// the macros during the juce include since they conflict.
#ifdef _CRTDBG_MAP_ALLOC
  #include <crtdbg.h>
  #include <stdlib.h>
  #include <malloc.h>

  #pragma push_macro("calloc")
  #pragma push_macro("free")
  #pragma push_macro("malloc")
  #pragma push_macro("realloc")
  #pragma push_macro("_recalloc")
  #pragma push_macro("_aligned_free")
  #pragma push_macro("_aligned_malloc")
  #pragma push_macro("_aligned_offset_malloc")
  #pragma push_macro("_aligned_realloc")
  #pragma push_macro("_aligned_recalloc")
  #pragma push_macro("_aligned_offset_realloc")
  #pragma push_macro("_aligned_offset_recalloc")
  #pragma push_macro("_aligned_msize")

  #undef calloc
  #undef free
  #undef malloc
  #undef realloc
  #undef _recalloc
  #undef _aligned_free
  #undef _aligned_malloc
  #undef _aligned_offset_malloc
  #undef _aligned_realloc
  #undef _aligned_recalloc
  #undef _aligned_offset_realloc
  #undef _aligned_offset_recalloc
  #undef _aligned_msize
#endif

#include "modules/juce_core/juce_core.h"

#ifdef _CRTDBG_MAP_ALLOC
  #pragma pop_macro("_aligned_msize")
  #pragma pop_macro("_aligned_offset_recalloc")
  #pragma pop_macro("_aligned_offset_realloc")
  #pragma pop_macro("_aligned_recalloc")
  #pragma pop_macro("_aligned_realloc")
  #pragma pop_macro("_aligned_offset_malloc")
  #pragma pop_macro("_aligned_malloc")
  #pragma pop_macro("_aligned_free")
  #pragma pop_macro("_recalloc")
  #pragma pop_macro("realloc")
  #pragma pop_macro("malloc")
  #pragma pop_macro("free")
  #pragma pop_macro("calloc")
#endif

hmmm… Thanks for the replies… :slight_smile: and the code… dint work :frowning: :frowning:
Anyways Thanks again.