title: C++ Singleton design pattern
body: <p>Recently I've bumped into a realization/implementation of the Singleton design pattern for C++. It has looked like this (I have adopted it from the real-life example):</p>
  <pre><code>// a lot of methods are omitted here
  class Singleton
  {
     public:
         static Singleton* getInstance( );
         ~Singleton( );
     private:
         Singleton( );
         static Singleton* instance;
  };
  </code></pre>
  <p>From this declaration, I can deduce that the instance field is initiated on the heap. That means there is a memory allocation. What is completely unclear for me is when exactly the memory is going to be deallocated? Or is there a bug and memory leak? It seems like there is a problem with the implementation.</p>
  <p>My main question is, how do I implement it in the right way?</p>