Unload a VST3?

And actually, looking for references to the JUCE singleton also led me to the culprint of this bug.
It’s called DLLHandleCache in juce_VST3PluginFormat.cpp

Basically once a specific dll gets added there, it never gets removed - since the DLLHandleCache itself is a singleton!

This method:

struct DLLHandleCache final : public DeletedAtShutdown
{
    DLLHandleCache() = default;
    ~DLLHandleCache() override { clearSingletonInstance(); }

    JUCE_DECLARE_SINGLETON (DLLHandleCache, false)

    DLLHandle& findOrCreateHandle (const String& modulePath)
    {
        //Other stuff to fetch the file and then:
        openHandles.push_back (std::make_unique<DLLHandle> (file));
    //...

This handle never gets removed until the host process/dll gets destroyed. So the OS still thinks we need this dll until the very end.

What we need here is some form of refcounting.

4 Likes