Leaking problems


#1

Hi guys !

I have a problem that occurs when I close the mainWindow, and I tried all day to debug it, still can’t figure it out…
Here’s the errors I’m getting :
> *** Leaked objects detected: 1 instance(s) of class OSXTypeface
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 1 instance(s) of class Typeface
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 4 instance(s) of class Label
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 4 instance(s) of class Font
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 4 instance(s) of class SimpleValueSource
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 4 instance(s) of class ValueSource
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 4 instance(s) of class AsyncUpdater
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 4 instance(s) of class Component
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 4 instance(s) of class MouseCursor
JUCE Assertion failure in juce_LeakedObjectDetector.h:95

I don’t know what I can provide you te help me, just ask whatever you want to see, I’ll answer you


#2

Well you aren’t deleting something. How complex is your app?


#3

Pretty complex actually… And to add more difficulty to it, I’m using the FlexBox feature, which is pretty new haha

Is there any components that I should particularly check in your opinion ?


#4

Maybe you can change any raw pointer you can find to ScopedPointer.
Edit: And OwnedArray not to be forgotten…
Remove the deletes and if you need to get rid of something immediately, set the ScopedPointer to nullptr.
HTH


#5

Any child components or your main content you instantiate via a call to new ? Start with those I guess.


#6

Alright thanks a lot for that !

I’ll check that and keep you updated


#7

Personally if you have a modern compiler I always try to use std::unique_ptr for ownership (shared_ptr if necessary) and then instantiate any dynamic components via std::make_unique.

A good practice to get into if you can in my opinion as it clearly expresses your intent and ownership. You know you shouldn’t have to stress too much over leaks if your typing std::make_unique for those child components.


#8

I’ll look into that too ! Thanks guys !


#9

If you get really stuck I’ve got a special leak detector version somewhere which tracks the call stack of the objects being constructed and then when you quit tells you exactly where the problem is … let me know if you need me to dig it up. It does make your program run very slowly though :slight_smile:

(found it: https://github.com/jcredland/juce-toys/blob/master/jcf_debug/source/advanced_leak_detector.h)


#10

@bazrush I’ve used this and it’s extremely useful!


#11

Alright I’m trying it right now ! Thanks


#12

I’m glad it’s found some use. It totally saved my bacon before. Doesn’t work on reference counted objects tho :frowning:

(Bacon saver:
)


#13

I found it thanks to your advanced leak detector ! It was a problem with Label attached to slider !

Thanks a lot to all of you guys, you’ve been a big help !


#14

Where do I get one of those? Looks extremely useful!


#15

My bacon never lasts long enough for saving. But I’ll keep an eye out for you…I bet lakeland have one. They sent us the catalogue once, and anywhere that has an avocado saver (see http://www.lakeland.co.uk/19461/2-Avocado-Food-Huggers) must also have a bacon saver somewhere