Disable leak detection


#1

Hi,
I’d like to know if there is anyway (perhaps a macro?) to deactivate juce leak detection. It keeps yelling at me whenever I have static data, and since I only have std::unique_ptrs in my code, I’m pretty sure I don’t have any actual leaks.

I know it’s only debug warnings, but they tend to muddle other very usefull juce asserts, as well as scaring me every time I debug a while after having added a static variable.


#2

Well, there’s a flag JUCE_CHECK_MEMORY_LEAKS

But I would say that I’ve worked on some huge, complex and gnarly projects but have never needed to disable it. If I were you I’d take that as an alarm bell that you maybe need to rethink your code structure.

Perhaps rather than static variables, you should try having a global state singleton that contains all the objects you need? Or try using SharedResourcePointer to create them on demand? Or just singletons which use DeletedAtShutdown to clean themselves up?


#3

Well, that’s what I’ve been doing to clean up my log, but I don’t think it’s always ideal. It’s mostly manager classes, like undo manager, audio format manager and command manager. I’ve wrapped all of them in singletons, but it felt like a hack since most of them don’t need initilization outside of their constructors.

so to disable leak detection I should use
#define JUCE_CHECK_MEMORY_LEAKS 0
?

thanks a lot for the tips