<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[valgrind und singleton pattern]]></title><description><![CDATA[<p>ich nutze das singleton pattern ziemlich oft,<br />
und irgendwie nervt es, das valgrind dann immer mem-leaks anzeigt,<br />
weiss wer wie man das vermeiden kann?</p>
<p>ich habe nun schon immer zum testen, den dtor des singleton wieder<br />
public gemacht, und es per delete() gelöscht, damit mich<br />
die meldungen nicht verwirren</p>
<p>hat da wer eine bessere lösung?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/207640/valgrind-und-singleton-pattern</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 03:55:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/207640.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 10 Mar 2008 10:16:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to valgrind und singleton pattern on Mon, 10 Mar 2008 10:16:26 GMT]]></title><description><![CDATA[<p>ich nutze das singleton pattern ziemlich oft,<br />
und irgendwie nervt es, das valgrind dann immer mem-leaks anzeigt,<br />
weiss wer wie man das vermeiden kann?</p>
<p>ich habe nun schon immer zum testen, den dtor des singleton wieder<br />
public gemacht, und es per delete() gelöscht, damit mich<br />
die meldungen nicht verwirren</p>
<p>hat da wer eine bessere lösung?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471322</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471322</guid><dc:creator><![CDATA[Treb]]></dc:creator><pubDate>Mon, 10 Mar 2008 10:16:26 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind und singleton pattern on Mon, 10 Mar 2008 10:17:50 GMT]]></title><description><![CDATA[<p>1. Singleton am Programmende zerstören (aufwändig und führt den Sinn ad absurdum)<br />
2. Statisches (Meyers-)Singleton verwenden</p>
<pre><code class="language-cpp">MyClass&amp; getInstance()
{
    static MyClass instance;
    return instance;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1471323</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471323</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Mon, 10 Mar 2008 10:17:50 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind und singleton pattern on Mon, 10 Mar 2008 10:31:29 GMT]]></title><description><![CDATA[<p>Du kannst dein Singeton mit ein bisschen RAII mischen...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
using namespace std;

class Singleton {
private:
   static Singleton* mInst;
public:
   Singleton() {
     if (mInst != 0) {
       throw &quot;Singleton darf nur einmal erstellt werden&quot;;
     }
     mInst = this;

     cout&lt;&lt;&quot;Erstellt&quot;&lt;&lt;endl;
   }

   ~Singleton() {
     mInst = 0;

     cout&lt;&lt;&quot;Geloescht&quot;&lt;&lt;endl;
   }

    void Hello() {
        cout&lt;&lt;&quot;Hello :)&quot;&lt;&lt;endl;    
    }

   inline static Singleton* Get() { return mInst; }

};

Singleton* Singleton::mInst = 0;

int main() {
    // alle Singletons, des Programms :)
    Singleton st1;

    Singleton::Get()-&gt;Hello();

    return EXIT_SUCCESS;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1471329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471329</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 10 Mar 2008 10:31:29 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind und singleton pattern on Mon, 10 Mar 2008 13:16:18 GMT]]></title><description><![CDATA[<p>oder mit einer Wächterklasse arbeiten.<br />
<a href="http://www.oop-trainer.de/Themen/Singleton.html" rel="nofollow">http://www.oop-trainer.de/Themen/Singleton.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1471427</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1471427</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 10 Mar 2008 13:16:18 GMT</pubDate></item></channel></rss>