TE 2.0: Memory Leaks at closing when using clip->setUsesProxy(false)

Hi Dave

When I call setUsesProxy(false) on a clip, this is what Visual Studio tells me when I close the application:
Detected memory leaks!
Dumping objects →

Object dump complete.

Cheers

How much is it dumping?
Are you sure it’s not just a couple of messages left on the message loop when you quit?

Here is my code:

class MainComponent : public AnimatedAppComponent
{
public:
	MainComponent() {
		centreWithSize(500, 500);
		trackInput->pluginList.insertPlugin(*samplerPlugin, 0, nullptr);
		TimeRange range = edit.tempoSequence.beatsToTime(BeatRange(0_bp, 4_bp));
		clip = dynamic_cast<tracktion_engine::MidiClip*> (trackInput->insertNewClip(tracktion_engine::TrackItem::Type::midi, "", range, nullptr));
		clip->setUsesProxy(false);
		clip->getSequence().addNote(72, BeatPosition::fromBeats(0), 1_bd, 127, 0, nullptr);
		transport.play(false);
	};

	void paint(Graphics& g) override { };

	void update() override { };

	tracktion_engine::Engine engine{ ProjectInfo::projectName };
	tracktion_engine::Edit::Options options{ engine, tracktion_engine::createEmptyEdit(engine), tracktion_engine::ProjectItemID::createNewID(0), tracktion_engine::Edit::forEditing };
	tracktion_engine::Edit edit{ options };
	tracktion_engine::TransportControl& transport{ edit.getTransport() };
	tracktion_engine::AudioTrack* trackInput{ edit.insertNewAudioTrack(tracktion_engine::TrackInsertPoint(nullptr, nullptr), nullptr).get() };
	tracktion_engine::MidiClip* clip;
	tracktion_engine::SamplerPlugin* samplerPlugin = dynamic_cast<tracktion_engine::SamplerPlugin*> (edit.getPluginCache().createNewPlugin(tracktion_engine::SamplerPlugin::xmlTypeName, {}).get());

	JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainComponent)
};

It is giving the following error at closing:

Detected memory leaks!
Dumping objects ->
{13772} normal block at 0x000001B000452AB0, 16 bytes long.
 Data: <                > F0 CD 14 C4 96 00 00 00 00 00 00 00 00 00 00 00 
{13769} normal block at 0x000001B000452830, 16 bytes long.
 Data: <xu              > 78 75 D3 7F B0 01 00 00 00 00 00 00 00 00 00 00 
{12348} normal block at 0x000001B000483CE0, 16 bytes long.
 Data: <`               > 60 C4 14 C4 96 00 00 00 00 00 00 00 00 00 00 00 
{12345} normal block at 0x000001B000483600, 16 bytes long.
 Data: <87D             > 38 37 44 00 B0 01 00 00 00 00 00 00 00 00 00 00 
Object dump complete.

If I change this line:

clip->setUsesProxy(true);

There is no more error at closing.

That’s weird. Those are very small blocks being dumped. I’m guessing it’s a few messages left on the dispatch loop but I’ll see if I can find out more detail.

It’s not a Tracktion thing, it’s just the good old JUCE win32 message memory leak. It’s been doing that for decades, and isn’t a real leak, just a couple of messages that were still on the queue when it exited.

It’s annoying because it keeps popping up as a bug report, but to IIRC the only way to avoid it would add a load of runtime overhead to the message queue, making it not worth doing.

Thank you for your reply.
I turned off these logs in debug mode by calling _CrtSetDbgFlag(0) at the beginning of the JUCEApplication::initialise function.