<?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[Befreien von Spiecher schlägt fehl]]></title><description><![CDATA[<p>Hi an alle,</p>
<p>folgendes Problem.<br />
Ich initialisiere mit new ein Array</p>
<pre><code class="language-cpp">LPOLESTR lpMicGuid = new WCHAR[39];
</code></pre>
<p>und arbeite damit.<br />
Nach dem ich es nicht mehr brauche will ich es mit delete löschen<br />
und bekomme vom compiler gesagt:<br />
Windows has triggered a breakpoint in DvVoipClient.exe.</p>
<p>This may be due to a corruption of the heap, and indicates a bug in DvVoipClient.exe or any of the DLLs it has loaded.</p>
<p>The output window may have more diagnostic information</p>
<p>Wenn ich aber kein Delete aus führe wird mir im Debug Modus ein<br />
Speicherleck an dieser stelle angezeigt.</p>
<p>Wie befreie ich denn den reservierten Speicher nun??</p>
<p>Gruß<br />
Crazy</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/229399/befreien-von-spiecher-schlägt-fehl</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 05:37:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/229399.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Dec 2008 09:43:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 09:43:34 GMT]]></title><description><![CDATA[<p>Hi an alle,</p>
<p>folgendes Problem.<br />
Ich initialisiere mit new ein Array</p>
<pre><code class="language-cpp">LPOLESTR lpMicGuid = new WCHAR[39];
</code></pre>
<p>und arbeite damit.<br />
Nach dem ich es nicht mehr brauche will ich es mit delete löschen<br />
und bekomme vom compiler gesagt:<br />
Windows has triggered a breakpoint in DvVoipClient.exe.</p>
<p>This may be due to a corruption of the heap, and indicates a bug in DvVoipClient.exe or any of the DLLs it has loaded.</p>
<p>The output window may have more diagnostic information</p>
<p>Wenn ich aber kein Delete aus führe wird mir im Debug Modus ein<br />
Speicherleck an dieser stelle angezeigt.</p>
<p>Wie befreie ich denn den reservierten Speicher nun??</p>
<p>Gruß<br />
Crazy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628675</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628675</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Thu, 11 Dec 2008 09:43:34 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 09:51:50 GMT]]></title><description><![CDATA[<p>Du solltest mal allen relevanten Code zeigen. Vermutlich machst du zwischen new und delete irgendwas böses mit dem Speicher...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628684</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628684</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 11 Dec 2008 09:51:50 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 09:56:18 GMT]]></title><description><![CDATA[<p>Das kann natürlich sein.</p>
<p>Hier der gesamte Code</p>
<pre><code class="language-cpp">LPOLESTR lpMicGuid = new WCHAR[39];
lpMicGuid = A2OLE(pVal);
GUID guid;
CLSIDFromString(lpMicGuid, &amp;guid);
m_lpGuidMic = (LPGUID)malloc(sizeof(GUID));
memcpy(m_lpGuidMic, &amp;guid, sizeof(guid));
if(lpMicGuid != NULL)
{
     delete lpMicGuid;
     lpMicGuid = NULL;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1628687</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628687</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Thu, 11 Dec 2008 09:56:18 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 09:56:59 GMT]]></title><description><![CDATA[<p>delete[]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628688</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628688</guid><dc:creator><![CDATA[vbdfbdf]]></dc:creator><pubDate>Thu, 11 Dec 2008 09:56:59 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 09:58:40 GMT]]></title><description><![CDATA[<p>Nein trotzdem der selbe Fehler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628690</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628690</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Thu, 11 Dec 2008 09:58:40 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:10:56 GMT]]></title><description><![CDATA[<p>Trotzdem musst du immer die richtige Variante benutzen (delete und delete[] sind ein Unterschied, siehe MSDN).</p>
<p>Warum verwendest du eigentlich abwechselnd new und malloc? Kann man zwar machen, aber du könntest deinen malloc-Aufruf genausogut durch new ersetzen und somit einheitlich bleiben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628699</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:10:56 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:13:27 GMT]]></title><description><![CDATA[<p>CrazyPlaya schrieb:</p>
<blockquote>
<pre><code class="language-cpp">LPOLESTR lpMicGuid = new WCHAR[39];
lpMicGuid = A2OLE(pVal);
</code></pre>
</blockquote>
<p>Und hier ist der mit new geholte Speicher schon nicht mehr erreichbar, weil der Zeiger nun auf den Rückgabewert von A2OLE zeigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628701</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:13:27 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:16:04 GMT]]></title><description><![CDATA[<p>Eieieiei....</p>
<pre><code class="language-cpp">// LPOLESTR lpMicGuid = new WCHAR[39];
// lpMicGuid = A2OLE(pVal); // falsch, überschreibt den Zeiger &quot;lpMicGuid&quot;, der somit nichtmehr auf den neu angeforderten Bereich zeigt,
                            // sondern auf einen Temporären Bereich der vom Makro A2OLE irgendwie herbeigezabuert wird
// besser &amp; einfacher:
std::wstring micGuidString = A2OLE(pVal);

// wieso so kompliziert?
// GUID guid;
// CLSIDFromString(lpMicGuid, &amp;guid);
// m_lpGuidMic = (LPGUID)malloc(sizeof(GUID)); // wieso malloc?
// memcpy(m_lpGuidMic, &amp;guid, sizeof(guid));
m_lpGuidMic = new GUID; // muss dann natürlich auch mit delete wieder freigegeben werden
CLSIDFromString(micGuidString.c_str(), m_lpGuidMic);

// fertig.

// brauchen wir jetzt nimmer, std::wstring räumt sich selbst auf
// if(lpMicGuid != NULL)
// {
//      delete lpMicGuid;
//      lpMicGuid = NULL;
// }
</code></pre>
<p>Und... wieso muss m_lpGuidMic überhaupt ein Zeiger sein? Ein einfaches Nicht-Zeiger-Member (&quot;GUID m_micGuid;&quot;) würde reichen. Oder ggf. ein boost::scoped_ptr&lt;GUID&gt; oder std::auto_ptr&lt;GUID&gt;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628703</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:16:04 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:19:43 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/2803">@MFK</a>: Stimmt, dann brauch ich den ja gar nicht mehr mit new initialisieren.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16702">@_matze</a>: Hast du schon recht. Die Abwechslung zwischen new und malloc kommt vom Copy and Paste:D:D.<br />
lalala <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/1628709</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628709</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:19:43 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:28:57 GMT]]></title><description><![CDATA[<p>Dann hab ich gleich noch eine Frage zur Speicherverwaltung.</p>
<p>ich habe eine Thread, dem ich über eine Struktur einen Zeiger auf eine Klasse übergebe.<br />
Z.B. so</p>
<pre><code class="language-cpp">MyClass myClass = new MyClass();
TPARAM tParam;
tParam.CMyClass = myClass;
hThread = CreateThread(NULL, 0, &amp;MyThread, &amp;tParam, 0, &amp;dwThreadId);
</code></pre>
<p>Und hier der Thread<br />
DWORD WINAPI CMyClass::MyThread(PVOID pParam)<br />
{<br />
TPARAM* tParam = (TPARAM*)pParam;<br />
CMyClass* myClass = pParam-&gt;myClass;<br />
}</p>
<p>Wie bereinige ich hier am Ende am besten meinen Speicher?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628725</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:28:57 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:42:08 GMT]]></title><description><![CDATA[<p>Kannst du die Instanz deiner Klasse nicht direkt im Thread erzeugen (und da wieder freigeben)? Du erzeugst ja sowieso erst kurz vorher eine neue Instanz. Oder wird die später noch gebraucht? Dann sollte das Freigeben vermutlich nix mi dem Thread zu tun haben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628746</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:42:08 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:49:20 GMT]]></title><description><![CDATA[<p>Ich benötige die Instanz der Klasse bereits vor dem Threadaufruf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628753</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:49:20 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:53:18 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">delete myClass;
</code></pre>
<p>oder</p>
<pre><code class="language-cpp">delete pParam-&gt;myClass;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1628759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628759</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:53:18 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:55:44 GMT]]></title><description><![CDATA[<p>Dann kann ich aber nach Abarbeitung des Threads nicht mehr mit der Instanz der Klasse weiterarbeiten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628760</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628760</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:55:44 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 10:58:33 GMT]]></title><description><![CDATA[<p>CrazyPlaya schrieb:</p>
<blockquote>
<p>Dann kann ich aber nach Abarbeitung des Threads nicht mehr mit der Instanz der Klasse weiterarbeiten.</p>
</blockquote>
<p>Du hattest auch nicht erwähnt, dass du das musst.<br />
Stell doch erst mal die Anforderungen auf, anstatt die Helfer vor die Wand laufen zu lassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628764</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628764</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 11 Dec 2008 10:58:33 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 11:01:31 GMT]]></title><description><![CDATA[<p>Ja, dann war dein Beispiel falsch. Da hast du nämlich eine frisch erzeugte Instanz and den Thread übergeben. So aber hat doch das Freigeben gar nix mit dem Thread zu tun. Dort ist die Instanz nur ein durchlaufender Posten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628766</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 11 Dec 2008 11:01:31 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 11:14:07 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/2803">@MFK</a>: Sorry, mein Fehler. Hats recht hätte ich erwähnen müssen.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16702">@_matze</a>: Das hab ich auch gedacht, aber irgendwo bleibt noch ein Speicherleck, in dem der Inhalt ist, welcher in dem Thread generiert wird.<br />
Daher habe ich angenommen dass innerhalb des Threads noch etwas nicht korrekt freigegeben wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628777</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Thu, 11 Dec 2008 11:14:07 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 11:18:29 GMT]]></title><description><![CDATA[<p>Du solltest einfach genau ein new und ein delete aufrufen. Dann sollte nix schiefgehen. Was macht denn der Thread? Weist du da noch mal Speicher zu oder machst sonstige krumme Sachen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628781</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628781</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 11 Dec 2008 11:18:29 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 11:29:11 GMT]]></title><description><![CDATA[<p>Ja so mach ich es ja bereits. Bevor ich den Thread aufrufe wird die Klasse instanziiert und dann bearbeitet. Dann Thread abarbeiten, hier wird kein neuer Speicher zugewiesen. Dann wird weiter mit der Instanz gearbeiten und beim Beenden wird ein delete ausgeführt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628784</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628784</guid><dc:creator><![CDATA[CrazyPlaya]]></dc:creator><pubDate>Thu, 11 Dec 2008 11:29:11 GMT</pubDate></item><item><title><![CDATA[Reply to Befreien von Spiecher schlägt fehl on Thu, 11 Dec 2008 12:25:01 GMT]]></title><description><![CDATA[<p>Hast du das mal mit Breakpoints überprüft? Passiert das auch, wenn du sämtliche Bearbeitungen auskommentierst (also nur new+delete)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1628817</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1628817</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 11 Dec 2008 12:25:01 GMT</pubDate></item></channel></rss>