OpenGL causing *** Leaked objects detected: 1 instance(s) of class StringArray


#1

All I have is quite simple, but I took it from the App demo, and this is running in a plug-in. I have this:

class EmptyPanel : public OpenGLAppComponent
{
public:

	EmptyPanel()
	{
		setSize(150, 150);
	}
	~EmptyPanel()
	{
		shutdownOpenGL();
	}
	void initialise() override
	{}
	void shutdown() override
	{}
	void render() override
	{}
	void paint(Graphics&) override
	{}
};

…In a new plug-in inititated by the Projucer. And the EmptyPanel as a member of editor and did an addAndMakeVisible(emptyPanel); in the editor constructor. But it appears the setSize is causing:
*** Leaked objects detected: 1 instance(s) of class StringArray
With a new instance of the StringArray error adding up everytime I open and close the editor from the DAW. What needs to be done please? And how to do I see the String it’s referring to, is it possible?
Thanks again,
Sorry for all the questions lately… :slight_smile:
edit I’m using VS2017 with the latest develop code but I think this also occurred in the master release.


#2

The leak counter is an assert statement, it only halts the execution, but it is safe to press continue. If you do that, you will most likely see other leaks as well. Did you try that? the other leaks (that may contain the StringArray, that happens to complain first) might give you a better clue about what is leaking.

The other thing is, I am not an OpenGL expert, but I think I would rather just use a standard Component and attach an OpenGLContext to it. I don’t see something directly related to JUCEApplication, but chances are, that the OpenGLAppComponent relies on mechanisms, that are not happening in a plugin.

Hope that helps


#3

I’ve been pressing continue for a week or so now. This is the only leak I have and it’s getting really annoying, TBH. The OpenGLAppComponent does all the things I want, including scaling properly in Windows with all the different scaling options, I’m a little cautious to change now I have three of them running nicely.
How do I find what’s in the StringArray in the asserting code?


#4

Unfortunately it is hard, the leak detector finds it, because it is orphaned (not owned anywhere, otherwise it would be destroyed on stack unrolling).
But a first step is to add in every class the macro JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyClass) (or one of the alternatives, there is JUCE_LEAK_DETECTOR (MyClass) for the ones you can copy as well).
Then you may find a leaking one, that contained your StringArray.

The JUCE classes should all have that macro, so if you find a class where it’s missing, please let the juce team know.


#5

Will do man, thanks.
In the meantime I just quickly did this, and it has the same assert error.

class EmptyPanel :	public Component,
				public OpenGLRenderer
{
public:
	OpenGLContext  openGLContext;
	EmptyPanel()
	{
		setSize(150, 150);
		openGLContext.setRenderer(this);
		openGLContext.attachTo(*this);
		openGLContext.setContinuousRepainting(true);
	}
	~EmptyPanel()
	{
		openGLContext.detach();
	}

	void newOpenGLContextCreated() override
	{}
	void openGLContextClosing() override
	{}

	void renderOpenGL() override
	{}
	void paint(Graphics&) override
	{}
};

#6

After a little further investigation this appears to be a VST3 only problem. Oh joy.
VST 2 and AAX versons have no jasserts - I haven’t tried MACOS yet…

…And everything appears to be OK on Mac. So basically it’s a Windows VST3 StringArray leak that only happens if I setSize or setBounds on an OpenGL Renderer.
It also needs an ‘addAndMakeVisible(emptyPanel);’ to go wrong.
:face_with_monocle: hmmm.


#7

Sounds like the issue I was also experiencing… however I was getting the assertion on macOS


#8

Interesting, thanks. The only code I use in the startup plugin fresh from the projucer is the above listing. Plus the add in the editor.


#9

I’ve been experiencing this issue on Windows + VST3 as well.


#10

Something in the latest dev code fixed this for me, I don’t know what - too busy to be to find out right now, sorry.


#11

Fixed here: