Memory Leaks on shutdown

Creating a completely blank plug-in project on ProJucer, I hit several memory leak assertions and finally an assertion in Singleton upon closing the DAW.

This does not happen when closing the editor window and then the host, only when the host is closed with the plug-in window open.

*** Leaked objects detected: 1 instance(s) of class OwnedArray
JUCE Assertion failure in juce_LeakedObjectDetector.h:92

*** Leaked objects detected: 1 instance(s) of class AsyncUpdater
JUCE Assertion failure in juce_LeakedObjectDetector.h:92

JUCE Assertion failure in juce_Singleton.h:50

Edit: the full SingletonHolder class name that asserts is:

juce::SingletonHolder<juce::ModalComponentManager, juce::DummyCriticalSection, false>
1 Like

A Singleton is a wrapper around a static variable, so it will be destroyed after the leak detector is evaluated.

My best advice is to avoid static included singleton at all cost.

If you still need the Singleton, use the class DeletedAtShutdown:

So if you’ve got a singleton and don’t want to have to explicitly delete it, just inherit from this and it’ll be taken care of.

2 Likes

I think you’re either a bot or you scraped the text a bit too quickly… :slight_smile:

I said:

Creating a completely blank plug-in project…

So, I wrote exactly 0 characters of code for this to happen.

Also, as a side note, after many years of writing C++ software I’ve literally never needed a singleton object for any application.

Which JUCE branch and which host?

Rail

v 7.0.10 - master

Tested on Reaper and Ableton Live with exactly the same behaviour.

Apologies, I misseedd that.

Could it be you have another plugin loaded?
Anyway, I didn’t observe that here.

Interesting… I actually don’t have any other plug-ins, I started a fresh project and simply opened the blank plug-in, then closed the host with the plug-in window still open.

Btw, I’m on an M1 Mac with JUCE v 7.0.10 on the master branch

I have the same issue, tested on macOS Sonoma and Monterey, with Reaper 7.03 (AU only, VST3 seems fine).

Steps to replicate:

  • compile the GainPlugin demo
  • run Reaper in debug
  • load GainPlugin (AU)
  • close Reaper
*** Leaked objects detected: 1 instance(s) of class OwnedArray
JUCE Assertion failure in juce_LeakedObjectDetector.h:92

I tested this on JUCE 7.0.10 but also on previous JUCE versions (and previous Reaper versions).

1 Like

Same issue since we bumped from an older version to 7.0.12

Only happens with AU project on macOS

I hit this today, I added the Heavy memleak detector but it doesnt really give me an idea where its ccoming from other than the ModalComponentManager

I confirm the AU fails with a leak of ModalComponentManager but VST3 works ok, this is with Reaper 7.16 and Juce 7.0.12.

Also occcurs with the juce8 branch and the develop branch too

I think the key thing is this only occcurs when you leave the plugin window open on quitting Reaper, if you close the plugins UI first, there is no leak.

1 Like

Thanks for your patience. A couple of fixes have been added on the develop branch:

Thanks! Did these make it to the Juce 8 release? The reason I ask is Im onnn Juce 8 and still get these. Im not on the develop branch though.

There has been no versioned release since these fixes were added. These changes will be included as soon as a new point release ships.

1 Like

Any chance we could get an official JUCE 7 branch where this kind of fixes could be cherry picked ?
Or will there never be any changes/fixes to JUCE 7 anymore?

3 Likes

I was able to validate this issue has been resolved on JUCE 8.0.2

1 Like