<?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 ausgabe]]></title><description><![CDATA[<p>hallo zusammen,</p>
<p>ich habe folgende valgrind ausgabe:</p>
<pre><code>==15746== 62 bytes in 2 blocks are definitely lost in loss record 286 of 775
==15746==    at 0x4A085C7: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==15746==    by 0x3780C9B860: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator&lt;char&gt; const&amp;) (in /usr/lib64/libstdc++.so.6.0.8)
==15746==    by 0x3780C9C364: ??? (in /usr/lib64/libstdc++.so.6.0.8)
==15746==    by 0x3780C9C511: std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, std::allocator&lt;char&gt; const&amp;) (in /usr/lib64/libstdc++.so.6.0.8)
==15746==    by 0x4659CA: TestApplication::handleEvent(AEvent*) (TestApplication.cc:1280)
==15746==    by 0x4D2319: EventGroup&lt;AEvent&gt;::sendTo(SubscriberSet, std::string) (AEvent.h:34)
==15746==    by 0x42A887: Dispatcher::process() (Dispatcher.cc:791)
</code></pre>
<p>an der entsprechenden stelle in der TestApplication wird folgendes gemacht:</p>
<pre><code>dis-&gt;signal( new BEvent(&quot;message&quot;));  //TestApplication.cc:1280
</code></pre>
<p>Und BEvent ist verkürzt:</p>
<pre><code>class BEvent : public BEventGroup&lt;BEvent&gt; {
        public:

            BEvent(const std::string &amp; s)
            : measurement(s) {
            }

        private:
            std::string measurement;
        };
</code></pre>
<p>Kann mir jemand erklären, woher der Fehler kommt und wie ich ihn wegbekomme? Valgrind habe ich mit valgrind -v --leak-check=yes aufgerufen.</p>
<p>Schon mal dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/323872/valgrind-ausgabe</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 10:52:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/323872.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Feb 2014 17:44:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 17:44:51 GMT]]></title><description><![CDATA[<p>hallo zusammen,</p>
<p>ich habe folgende valgrind ausgabe:</p>
<pre><code>==15746== 62 bytes in 2 blocks are definitely lost in loss record 286 of 775
==15746==    at 0x4A085C7: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==15746==    by 0x3780C9B860: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator&lt;char&gt; const&amp;) (in /usr/lib64/libstdc++.so.6.0.8)
==15746==    by 0x3780C9C364: ??? (in /usr/lib64/libstdc++.so.6.0.8)
==15746==    by 0x3780C9C511: std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, std::allocator&lt;char&gt; const&amp;) (in /usr/lib64/libstdc++.so.6.0.8)
==15746==    by 0x4659CA: TestApplication::handleEvent(AEvent*) (TestApplication.cc:1280)
==15746==    by 0x4D2319: EventGroup&lt;AEvent&gt;::sendTo(SubscriberSet, std::string) (AEvent.h:34)
==15746==    by 0x42A887: Dispatcher::process() (Dispatcher.cc:791)
</code></pre>
<p>an der entsprechenden stelle in der TestApplication wird folgendes gemacht:</p>
<pre><code>dis-&gt;signal( new BEvent(&quot;message&quot;));  //TestApplication.cc:1280
</code></pre>
<p>Und BEvent ist verkürzt:</p>
<pre><code>class BEvent : public BEventGroup&lt;BEvent&gt; {
        public:

            BEvent(const std::string &amp; s)
            : measurement(s) {
            }

        private:
            std::string measurement;
        };
</code></pre>
<p>Kann mir jemand erklären, woher der Fehler kommt und wie ich ihn wegbekomme? Valgrind habe ich mit valgrind -v --leak-check=yes aufgerufen.</p>
<p>Schon mal dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384272</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384272</guid><dc:creator><![CDATA[sven_]]></dc:creator><pubDate>Thu, 20 Feb 2014 17:44:51 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 18:04:28 GMT]]></title><description><![CDATA[<p>Wo wird das Event gelöscht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384274</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Thu, 20 Feb 2014 18:04:28 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 18:11:03 GMT]]></title><description><![CDATA[<p>hallo manni,</p>
<p>in der angegebenen zeile. laut log wird es auch verarbeitet vom eventhandler und der löscht am ende alle events.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384276</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384276</guid><dc:creator><![CDATA[sven_]]></dc:creator><pubDate>Thu, 20 Feb 2014 18:11:03 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 18:15:33 GMT]]></title><description><![CDATA[<p>In der angegebenen Zeile wird nichts gelöscht! Wer sagt, dass der Eventhandler die Events löscht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384277</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Thu, 20 Feb 2014 18:15:33 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 18:18:54 GMT]]></title><description><![CDATA[<p>sven_ schrieb:</p>
<blockquote>
<p>in der angegebenen zeile. laut log wird es auch verarbeitet vom eventhandler und der löscht am ende alle events.</p>
</blockquote>
<p>Entweder stimmt diese Aussage nicht und der eventhandler kümmert sich nicht um die Freigabe, obwohl er die Verantwortung für die Ressource hat. Oder der eventhandler ist fehlerhaft programmiert, zum Beispiel könnte er ein Ressourcenhandler sein, der die Regel der großen Drei verletzt.</p>
<p>Ich tippe mal auf letzteres.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384278</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 20 Feb 2014 18:18:54 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 18:28:57 GMT]]></title><description><![CDATA[<p>hallo zusammen,</p>
<p>die regel der großen drei????</p>
<p>der eventhandler ist im dispatcher beheimatet und sieht im process schritt wie folgt aus:</p>
<pre><code>void
        Dispatcher::process() {

            if (pendingObjects.size() &gt; 0) {

                DEBUG(&quot;process - Processing &quot; &lt;&lt; pendingObjects.size() &lt;&lt; &quot; pending objects: &quot; &lt;&lt; pendingObjects);
                DeliverableObject * object;
                for (auto o = pendingObjects.begin(); o != pendingObjects.end();) {
                    object = *o;

                    if (object != NULL) {
                        DEBUG(&quot;process - Processing &quot; &lt;&lt; object &lt;&lt; &quot;, groups: &quot; &lt;&lt; object-&gt;getGroups());

                        GroupList groups = object-&gt;getGroups();
                        for (auto g = groups.begin(); g != groups.end(); g++) {
                            SubscriberSet subscribers = subscriptions[*g];
                            DEBUG(&quot;process - Type &quot; &lt;&lt; *g &lt;&lt; &quot; has &quot; &lt;&lt; subscribers.size() &lt;&lt; &quot; subscribers&quot;);

                            if (subscribers.size() &gt; 0) {
                                object-&gt;sendTo(subscribers, *g);
                            }
                        }
                    }
                    else {
                        DEBUG(&quot;process - Error: Object is NULL! Delivery aborted.&quot;);
                    }

                    // The iterator &lt;o&gt; used here has to be reinitialized after each
                    // erase operation to ensure its sanity.
                    o = pendingObjects.erase(o);

                    DEBUG(&quot;process - Finished &quot; &lt;&lt; object);
                    DEBUG(&quot;process - &quot; &lt;&lt; pendingObjects.size() &lt;&lt; &quot; objects left.&quot;)
                    delete object; //&lt;&lt;--- lösche event ?!
                }
                DEBUG(&quot;process - Finished processing pending objects.&quot;);
            }
        }
</code></pre>
<p>Das ganze haben wir selbst geschrieben und basiert auf dem Curiously recurring template pattern.<br />
<a href="http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern" rel="nofollow">http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern</a></p>
<p>wir nutzen da die type_info einer klasse um sich für einen event zu registrieren. tut eigentlich ganz gut, bis auf das valgrind gemaule. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Der output sagt:</p>
<pre><code>DIS@192.168.0.1:100 process - Processing BEvent [Measurement: REJOIN], groups: [EventE, PN6BEventE, PN618BEventE]
DIS@192.168.0.1:100 process - Type EventE has 1 subscribers
DIS@192.168.0.1:100 process - Type PN6BEventE has 1 subscribers
DIS@192.168.0.1:100 process - Finished BEvent [Measurement: REJOIN]
DIS@192.168.0.1:100 process - 0 objects left.
</code></pre>
<p>Daher nehm ich an, dass es auch gelöscht wird bei delete im obigen code. oder irre ich hier?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384282</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384282</guid><dc:creator><![CDATA[sven_]]></dc:creator><pubDate>Thu, 20 Feb 2014 18:28:57 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 18:45:28 GMT]]></title><description><![CDATA[<p>Wie stehen <code>DeliverableObject</code> und <code>BEvent</code> in Beziehung zueinander? Wie werden BEvents in <code>pendingObjects</code> eingefuegt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384286</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384286</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 20 Feb 2014 18:45:28 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 18:44:48 GMT]]></title><description><![CDATA[<p>Hat DeliverableObject einen virtuellen Destruktor? Sonst wird nämlich immer nur das Basisklassenteilobjekt aufgeräumt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384287</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384287</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Thu, 20 Feb 2014 18:44:48 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 18:46:47 GMT]]></title><description><![CDATA[<blockquote>
<p>Hat DeliverableObject einen virtuellen Destruktor?</p>
</blockquote>
<p>DeliverableObject koennte auch ein BEvent-Zeiger als Member haben, ohne virtuellen Destruktor.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384288</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384288</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 20 Feb 2014 18:46:47 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 19:01:30 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<blockquote>
<p>Hat DeliverableObject einen virtuellen Destruktor?</p>
</blockquote>
<p>DeliverableObject koennte auch ein BEvent-Zeiger als Member haben, ohne virtuellen Destruktor.</p>
</blockquote>
<p>Dann ist das gezeigte delete nicht das, welches das Event löscht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384289</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384289</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Thu, 20 Feb 2014 19:01:30 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Thu, 20 Feb 2014 19:57:30 GMT]]></title><description><![CDATA[<p>manni66 schrieb:</p>
<blockquote>
<p>knivil schrieb:</p>
<blockquote>
<blockquote>
<p>Hat DeliverableObject einen virtuellen Destruktor?</p>
</blockquote>
<p>DeliverableObject koennte auch ein BEvent-Zeiger als Member haben, ohne virtuellen Destruktor.</p>
</blockquote>
<p>Dann ist das gezeigte delete nicht das, welches das Event löscht.</p>
</blockquote>
<p>Whatever, der Destruktor kann aber das Event loeschen und dann waere gezeigtes delete dafuer verantwortlich. Es bringt jetzt nichts alle Moeglichkeiten durchzuraten. Es koennte auch ganz anders sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384295</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384295</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 20 Feb 2014 19:57:30 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Fri, 21 Feb 2014 09:38:21 GMT]]></title><description><![CDATA[<p>hallo zusammen,</p>
<p>sorry, gestern abend war ich unterwegs und hab nicht mehr reingeschaut. freut mich, dass die frage soviel interesse weckt! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>es scheint in der tat der fehlende virtuelle konstruktor gewesen zu sein. diesen hinzugefügt und valgrind ist glücklich. heißt das, wenn delete aufgerufen wurde, dass da nur das deliverableObject gelöscht wurde, und die darauf aufbauenden events blieben übrig?</p>
<p>was sind nochmal die großen drei?</p>
<p>ich danke euch vielmals. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384342</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384342</guid><dc:creator><![CDATA[sven_]]></dc:creator><pubDate>Fri, 21 Feb 2014 09:38:21 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Fri, 21 Feb 2014 10:13:45 GMT]]></title><description><![CDATA[<p><a href="https://www.google.de/?gfe_rd=cr&amp;ei=YCYHU5rvMMeP_AaMl4D4BA#q=die+gro%C3%9Fen+drei+c%2B%2B" rel="nofollow">die großen drei c++</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384347</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384347</guid><dc:creator><![CDATA[Google]]></dc:creator><pubDate>Fri, 21 Feb 2014 10:13:45 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Fri, 21 Feb 2014 10:14:15 GMT]]></title><description><![CDATA[<p>Bitte beantworte doch erstmal die Frage, wie beide Klassen in Beziehung stehen.</p>
<blockquote>
<p>da nur das deliverableObject gelöscht wurde, und die darauf aufbauenden events blieben übrig</p>
</blockquote>
<p>Das kommt drauf an, wie die Klassen zueinander in Beziehung stehen. Ansosnte: Ja, wenn <code>BEventGroup&lt;BEvent&gt;</code> von <code>DeliverableObject</code> erbt.</p>
<p>Ansosnten: CRTP nutzen aber Grundlagen nicht verstehen. Irgendwas laeuft falsch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384348</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384348</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Fri, 21 Feb 2014 10:14:15 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Fri, 21 Feb 2014 10:33:31 GMT]]></title><description><![CDATA[<p>ja, ein event ist ein deliverable object.</p>
<p>crtp haben wir ja nicht genommen weil es so fancy ist, sondern weil es der einzige weg war, den wir gefunden hatten um das abonnieren von eventgruppen zu ermöglichen. lieber wäre es mir ohne gewesen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384353</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384353</guid><dc:creator><![CDATA[sven_]]></dc:creator><pubDate>Fri, 21 Feb 2014 10:33:31 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Fri, 21 Feb 2014 10:37:02 GMT]]></title><description><![CDATA[<p>nachtrag:</p>
<p>das man copy constructor, zuweisungs operator und destructor immer angeben soll weiß ich. mir war es bloß nicht unter dem begriff der großen drei geläufig und da der hinweis bezüglich des eventhandlers gemacht wurde auch gerade nicht klar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384354</guid><dc:creator><![CDATA[sven_]]></dc:creator><pubDate>Fri, 21 Feb 2014 10:37:02 GMT</pubDate></item><item><title><![CDATA[Reply to valgrind ausgabe on Fri, 21 Feb 2014 11:16:55 GMT]]></title><description><![CDATA[<p>sven_ schrieb:</p>
<blockquote>
<p>das man copy constructor, zuweisungs operator und destructor immer angeben soll weiß ich.</p>
</blockquote>
<p>Das ist aber falsch. Die Regel der Grossen Drei besagt nur, dass <strong>wenn</strong> du einen der drei implementierst, du dann meistens auch die anderen zwei brauchst. In C++11 ist es mit Move-Konstruktor und Move-Zuweisungsoperator die Regel der Grossen Fünf.</p>
<p>Ich würde sogar behaupten, im Allgemeinen ist es gut, wenn man diese Memberfunktionen dem Compiler überlassen kann. Es zeigt nämlich, dass man gut von Low-Level-Operationen wie Speicherverwaltung, Kopieren, etc. abstrahiert hat und sich Objekte selbst kopieren/verschieben können. Gibt natürlich Fälle, wo eine Implementierung trotzdem nötig ist, meist wegen Exceptionsicherheit.</p>
<p>Interessanter Artikel: <a href="http://flamingdangerzone.com/cxx11/2012/08/15/rule-of-zero.html" rel="nofollow">Rule Of Zero</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2384365</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2384365</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 21 Feb 2014 11:16:55 GMT</pubDate></item></channel></rss>