[RCF::getRootMutex] Memory Leak ?

RCF support and general discussion.
Post Reply
acDev
Posts: 27
Joined: Tue Oct 08, 2013 3:08 pm
Location: Moscow
Contact:

[RCF::getRootMutex] Memory Leak ?

Post by acDev »

Original:

Code: Select all

    Mutex & getRootMutex()
    {
        static Mutex * gpRootMutex = new Mutex;
        return *gpRootMutex;
    }
My way:

Code: Select all

    Mutex gRootMutex;

    Mutex & getRootMutex()
    {
        return gRootMutex;
    }

jarl
Posts: 238
Joined: Mon Oct 03, 2011 4:53 am
Contact:

Re: [RCF::getRootMutex] Memory Leak ?

Post by jarl »

The purpose of the root mutex is to provide thread safe initialization and deinitialization. As such it has to exist permanently, which is why we don't delete it.

It's not a memory leak, as there is only ever one such mutex.
Kind Regards

Jarl Lindrud
Delta V Software
http://www.deltavsoft.com

Post Reply