42template <
class OwnerClass>
57 struct BacktraceMapHolder
59 BacktraceMapHolder() =
default;
65 DBG (
"*** Leaked objects detected: " << map.size() <<
" instance(s) of class " << getLeakedObjectClassName());
66 DBG (getFormattedBacktracesString());
80 String getFormattedBacktracesString()
const
87 str <<
"\nBacktrace " <<
String (counter++) <<
"\n"
88 <<
"-----------------------------------------------------------------" <<
"\n"
100 static BacktraceMapHolder holder;
104 static const char* getLeakedObjectClassName()
106 return OwnerClass::getLeakedObjectClassName();
111#if DOXYGEN || ! defined (JUCE_HEAVYWEIGHT_LEAK_DETECTOR)
112 #if (DOXYGEN || JUCE_CHECK_MEMORY_LEAKS)
135 #define JUCE_HEAVYWEIGHT_LEAK_DETECTOR(OwnerClass) \
136 friend class juce::HeavyweightLeakedObjectDetector<OwnerClass>; \
137 static const char* getLeakedObjectClassName() noexcept { return #OwnerClass; } \
138 juce::HeavyweightLeakedObjectDetector<OwnerClass> JUCE_JOIN_MACRO (leakDetector, __LINE__);
140 #define JUCE_HEAVYWEIGHT_LEAK_DETECTOR(OwnerClass)
This class is a useful way of tracking down hard to find memory leaks when the regular LeakedObjectDe...
static String getStackBacktrace()
Returns a backtrace of the current call-stack.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...