Method for counting instances of a plug-in


Is there a safe way for counting the number of intances of a certain plug-in running inside a host?

a static int? Should be pretty safe.

yeah i always do something like:


class MyPlugin { //... static int numInstances; //...


[code]int MyPlugin::numInstances = 0;

MyPlugin::~MyPlugin ()
if (–MyPlugin::numInstances == 0)
// shared deinitialization when all instances off

AudioFilterBase* createPluginFilter()
if (MyPlugin::numInstances++ == 0)
// shared initialization among instances

return new MyPlugin();


and it works like a charm !

thanks, thats a good idea that I didn’t think of.