# Revision history [back]

This leak is real and caused by: sources\modules\core\src\system.cpp...

static Mutex* __initialization_mutex = NULL;
Mutex& getInitializationMutex()
{
if (__initialization_mutex == NULL)
__initialization_mutex = new Mutex();
return *__initialization_mutex;
}


The problem is that there is a new and no matching delete. Since this pointer is a singleton, it only results in a leak when the application closes (so not REALLY a leak). However, if (like me) you are trying to find leaks in your own code reports such as this distract you from your task.

The fix for this leak that I am using is:

static Mutex* __initialization_mutex = NULL;
void deleteInitializationMutex()
{
if (NULL != __initialization_mutex)
{
delete __initialization_mutex;
__initialization_mutex = NULL;
}
}
Mutex& getInitializationMutex()
{
if (__initialization_mutex == NULL)
{
__initialization_mutex = new Mutex();
atexit( deleteInitializationMutex );
}
return *__initialization_mutex;
}


If anybody wants to add this (or something like it) to the official code I would really appreciate it.