Leaked objects detected: SimpleDeviceManagerInputLevelMeter


#1

Hi,

I am a total beginner to Juce, but because of its apparent strength with regards to audio processing, I wanted to try it out for some ham radio applications that I am playing with. I have my hello world up and running, that plays sound that I have generated.

But on shutdown I am struggeling with this error:

'SoftRockCw.exe': Unloaded 'C:\Windows\SysWOW64\shdocvw.dll'
*** Leaked objects detected: 1 instance(s) of class SimpleDeviceManagerInputLevelMeter
JUCE Assertion failure in juce_leakedobjectdetector.h:95
SoftRockCw.exe has triggered a breakpoint

What my program does in startup is (Please forgive my break with coding standards, I work in a hardcore K&R environment, and habits like that are difficult to break with) :

	mDevManager = new AudioDeviceManager();
	mDevManager->initialise(0,2,NULL,true);
	mSelector = new AudioDeviceSelectorComponent(*mDevManager,0,2,2,2,false,false,true,true);
	mDevManager->addAudioCallback(static_cast<juce::AudioIODeviceCallback*>(&mCallback));

The UI is a single window with various tabs for control, and I add the mSelector to a new (static) tab as follows:

	tabbedComponent->addTab(tabName,tabBackgroundColour,contentComponent,false);

The leak / assert happens when I shut down the program (press red button with mouse) - Using the debugger I see that SimpleDeviceManagerInputLevelMeter is created, deleted, then created again, but never deleted before the leak check. If I try to delete delete the selector myself, I run into a double free - which is even worse :frowning:

I am suspecting that the audio selector was not intended to be a permanent fixture of the UI , and there could be a problem when tearing down the app when audio devices and the selector components are active. Either that or I have done some other silly beginners mistake. Any help or hints will be much appreciated. Oh an my Juce version is master from 09/05/2013.


#2

It seems that the reported leak goes away if I add input devices to the device manager thusly:

-  mDevManager->initialise(0,2,NULL,true);
+ mDevManager->initialise(2,2,NULL,true);

So maybe the leak is a result of the input level meter not having been used in the selector.

EDIT: But now I get even more leaks reported from RowComponents that were created by the AudioDeviceSelectorComponent

*** Leaked objects detected: 4 instance(s) of class RowComponent
JUCE Assertion failure in juce_leakedobjectdetector.h:95
SoftRockCw.exe has triggered a breakpoint

#3

I think you’re probably just leaking the entire device selector component. There’s certainly no way for a SimpleDeviceManagerInputLevelMeter to leak unless you allow its parent to leak.


#4

Thanks, that seems to have been the case. Instead of manually deleting the component which caused an even worse error (crash), I simply changed:

-  tabbedComponent->addTab(tabName,tabBackgroundColour,contentComponent,false);
+  tabbedComponent->addTab(tabName,tabBackgroundColour,contentComponent,true);

The UI component cleanup then seems to do a much better job than my manual delete. :smiley:

As for the project itself, progress has been very promising, I am now able to generate morse code realtime, something that requires quite low latency in order to be able to operate the paddle correctly based on the auditory feedback. I still have quite a bit of signal processing to do, but will push my code to github (GPL), as soon as it becomes even slightly usable.

So far using Juce has been a pleasant experience, and the new web site looks good! Fingers crossed that things stay this way :wink: