surge-synthesizer / monique-monosynth

Monique monosynth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: memory leak on shut down

TommmyArn opened this issue · comments

The class SHARED is a singleton which will be no more deleted on shutdown, because of the removals of IS_PLUGIN and IS_STANDALONE (a66d3cf). To keep the feature (sharing data and global settings between serval plugin instances) the class or the members could be reference counted and safely freed.

commented

There's a really cool juce6 delete on shutdown object juce::DeletedAtShutdown where juce makes sure - well - it gets deleted at shutdown!

Here's how i used to to clean up some files

 static struct filesToDelete : juce::DeletedAtShutdown
    {
        ~filesToDelete()
        {
            for (const auto &d : deleteThese)
            {
                d.deleteFile();
            }
        }
        std::vector<juce::File> deleteThese;
    } *byebyeOnExit = new filesToDelete();

then adding things to the vector means sure we kill them on exit

Probably use same pattern here?

commented

Yeah that does it.

This is another bit of code which I think could benefit from unique_ptr ing but the delete fix works. I'll push up a PR in a second.

commented

Welll we weren't sure that was right so i reverted it and reopened this!