Since I don’t want multiple instances of my app, I’m returning false from moreThanOneInstanceAllowed. However, the second instance leaks memory.
I was able to get rid of most of them by changing part of JUCEApplication::enterMainApplicationLoop from this:
if (! app->moreThanOneInstanceAllowed())
{
appLock = new InterProcessLock (T("juceAppLock_") + app->getApplicationName());
if (! appLock->enter(0))
{
MessageManager::broadcastMessage (app->getApplicationName()
+ T("/") + *commandLine);
delete appInstance;
appInstance = 0;
delete commandLine;
return;
}
}[/code]
to this:
[code] if (! app->moreThanOneInstanceAllowed())
{
appLock = new InterProcessLock (T("juceAppLock_") + app->getApplicationName());
if (! appLock->enter(0))
{
MessageManager::broadcastMessage (app->getApplicationName()
+ T("/") + *commandLine);
delete appInstance;
appInstance = 0;
delete commandLine;
// ***************
// added these lines
shutdownJuce_GUI();
delete appLock;
// ***************
return;
}
}
This took care of most of the leaks. However, I’m still leaking a Message object. As near as I can tell, it’s being generated by the idle timer for the message loop. I don’t see any obvious way to ensure that this gets cleaned up properly.
Any suggestions?
Thanks,
Matt
