I recently came upon a C++ realization/implementation of the Singleton design pattern.
It looked like this (I took it from a real-life example):
// a lot of methods are omitted here
class Singleton
{
public:
static Singleton* getInstance( );
~Singleton( );
private:
Singleton( );
static Singleton* instance;
};
I may conclude from this declaration that the instance field is created on the heap.
This indicates that memory has been allocated.
What is entirely unknown to me is when the memory will be deallocated.
Is there a problem or a memory leak?
There appears to be an issue with the implementation.
My primary concern is how to execute it correctly.