# Disable leak detection

**URL:** <https://forum.juce.com/t/disable-leak-detection/24738>\
**Category:** General JUCE discussion\
**Created:** [October 20, 2017, 11:07am UTC](https://forum.juce.com/t/disable-leak-detection/24738 "2017-10-20T11:07:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![claudiocabral](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@claudiocabral](https://forum.juce.com/u/claudiocabral)\
**Post date:** [October 20, 2017, 11:07am UTC](https://forum.juce.com/t/disable-leak-detection/24738/1 "2017-10-20T11:07:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 20, 2017, 11:18am UTC](https://forum.juce.com/t/disable-leak-detection/24738/2 "2017-10-20T11:18:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![claudiocabral](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@claudiocabral](https://forum.juce.com/u/claudiocabral)\
**Post date:** [October 20, 2017, 11:29am UTC](https://forum.juce.com/t/disable-leak-detection/24738/3 "2017-10-20T11:29:57Z")

</div>

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
