Strange memory leak from MessagManager

#1

Hello, when trying to load a plugin using this code:

    OwnedArray<PluginDescription> pluginDescriptions;
    KnownPluginList pluginList;
    AudioPluginFormatManager pluginFormatManager;
    
    pluginFormatManager.addDefaultFormats();
    
    for (int i = pluginFormatManager.getNumFormats(); --i >= 0;)
    {
        pluginList.scanAndAddFile (String (path),
                                   true,
                                   pluginDescriptions,
                                   *pluginFormatManager.getFormat(i));
    }

I get:
***** Leaked objects detected: 1 instance(s) of class MessageManager**

JUCE Assertion failure in juce_LeakedObjectDetector.h:90

Does someone know what can be the problem? Thanks!

0 Likes

#2

Are you trying this without a GUI?
The MessageManager is a singleton, in a GUI app it will be destroyed automatically.
In a console app or anything, that doesn’t call the JUCE_START_APPLICATION (MyApp) macro,
you have to add a ScopedJuceInitialiser__GUI, that will clean up when going out of scope.

Hope that helps.

1 Like

#3

Thank you Daniel, it helps!

0 Likes