How to unload dll plugin when shutdown JUCE application?


#1

I’m creating a Window application by using JUCE Framework and VST to load UI dll plugin for each components.
Now my issue is when shutdown application only GUI turns off, but process still works.
I opened the Window task manager and see the process still running, it really weird.
Then I have used Visual studio debug feature to find the root cause and seems Plugin is not unloaded so process cannot terminate.
My question here is how can I unload dll plugin which loaded by VST when shutdown JUCE application?


#2

Just having a DLL loaded won’t keep your process alive if the messagemanager has shut down. I bet you’ve probably just not shutdown properly or deleted all your objects. If the VST DLLs are still loaded then you mustn’t have deleted all the plugin instance objects that you created, because they automatically clean up the DLLs when no longer needed.


#3

@jules

When user clicks to exit button, on host plugin, I just call JUCEApplication::quit() and don’t do anything else.

case fileExit:
{
JUCEApplication::quit();
break;
}
I have checked the output on Visual studio, and saw that current dll plugin(plugin_1) is not unloaded.
The thread 0x2994 has exited with code 0 (0x0).
‘my_app.exe’ (Win32): Unloaded ‘D:\working\my_project\plugin_2.dll’
‘my_app.exe’ (Win32): Unloaded ‘D:\working\my_project\plugin_3.dll’


#4

Well presumably you’re leaking the plugin instances that loaded it?


#5

I have used OwnedArray<> to store PluginDescription and AudioProcessor.

OwnedArray pluginDescription; // description for plugin_1, plugin_2, plugin_3
OwnedArray listUI; // ui for plugin_1, plugin_2, plugin_3

And use createPluginInstanceAsync() to load plugins.:

AudioPluginFormatManager.createPluginInstanceAsync(*pluginDescription.getUnchecked(index), 1, 1, new AsyncCallback(this));


#6

Well it’s not really possible for us to guess what your app is doing, but surely it’s easy enough for you to debug this? Try looking at the ModuleHandle class in the VST code, which is where it keeps references to the DLLs and loads/releases them.

(And also look at the plugin host demo, which exits without any problems)


#7

Tested with every 3rd party plugin ever created? :wink: