<?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[new &amp;amp; delete]]></title><description><![CDATA[<p>Das müsste doch theoretisch 10000 x 10 Byte, also 100 KB Arbeitsspeicher fressen:</p>
<pre><code class="language-cpp">int *x = new int[10000];
    for(int i = 0; i &lt; 10000; i++)
        x[i] = 123456;
</code></pre>
<p>Tut es aber nicht, der Arbeitsspeicher wird nicht belastet.</p>
<p>Und ein delete [] x; funktioniert auch nicht! Warum?</p>
<p>Kommt nur ein schwerer Fehler irgendwas mit blabla.IsValidPointer(pUserData)..</p>
<p>Der obere Code steht im Konstruktor einer Klasse und im Destruktor steht daweil nichts weil delete ja nicht funktioniert.<br />
Sonst nur eine private: int *x;</p>
<p>In der main steht nur</p>
<p>Test test;</p>
<p>Halt eine Instanz erstellen, und dann hab ich cin &gt;&gt; blabla gemacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/143165/new-amp-delete</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 03:07:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/143165.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Apr 2006 21:17:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to new &amp;amp; delete on Wed, 05 Apr 2006 21:17:53 GMT]]></title><description><![CDATA[<p>Das müsste doch theoretisch 10000 x 10 Byte, also 100 KB Arbeitsspeicher fressen:</p>
<pre><code class="language-cpp">int *x = new int[10000];
    for(int i = 0; i &lt; 10000; i++)
        x[i] = 123456;
</code></pre>
<p>Tut es aber nicht, der Arbeitsspeicher wird nicht belastet.</p>
<p>Und ein delete [] x; funktioniert auch nicht! Warum?</p>
<p>Kommt nur ein schwerer Fehler irgendwas mit blabla.IsValidPointer(pUserData)..</p>
<p>Der obere Code steht im Konstruktor einer Klasse und im Destruktor steht daweil nichts weil delete ja nicht funktioniert.<br />
Sonst nur eine private: int *x;</p>
<p>In der main steht nur</p>
<p>Test test;</p>
<p>Halt eine Instanz erstellen, und dann hab ich cin &gt;&gt; blabla gemacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031453</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031453</guid><dc:creator><![CDATA[Blödl]]></dc:creator><pubDate>Wed, 05 Apr 2006 21:17:53 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Wed, 05 Apr 2006 21:30:26 GMT]]></title><description><![CDATA[<blockquote>
<p>Tut es aber nicht, der Arbeitsspeicher wird nicht belastet.</p>
</blockquote>
<p>Woran erkennst du das?</p>
<p>IsValidPointer überprüft ob das ein gültiger pointer ist den du da rein gibts, ist bei dir nicht der fall, also ist das nicht mehr das x was du von new bekommen hast, oder du hast den heap kaputt gemacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031461</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031461</guid><dc:creator><![CDATA[CMatt]]></dc:creator><pubDate>Wed, 05 Apr 2006 21:30:26 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Wed, 05 Apr 2006 21:34:35 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// *** INCLUDES *** //
#include &quot;main.h&quot;

// *** CLASSES *** //
class Test
{
    int *x;
public:
    Test(short);
    ~Test();
};

Test::Test(short c)
{
    int *x = new int[c];
    for(int i = 0; i &lt; c; i++)
        x[i] = 14535344;
}

Test::~Test()
{
    ;
}

// *** MAIN FUNCTION *** //
int main()
{
    Test::Test(c);

    cin &gt;&gt; c;

    return 0;
}
</code></pre>
<pre><code class="language-cpp">#ifndef MAIN_H
#define MAIN_H

// *** INCLUDES *** //
#include &lt;windows.h&gt;
#include &lt;iostream&gt;
using namespace std;

#endif // MAIN_H
</code></pre>
<p>Erkennen kann man das am TaskManager oder mit dem Process Explorer.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031463</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031463</guid><dc:creator><![CDATA[Blödl]]></dc:creator><pubDate>Wed, 05 Apr 2006 21:34:35 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Wed, 05 Apr 2006 21:42:02 GMT]]></title><description><![CDATA[<p>Ich meinte natürlich:</p>
<p>[cpp]<br />
// *** MAIN FUNCTION *** //<br />
int main()<br />
{<br />
Test test;</p>
<p>int c;<br />
cin &gt;&gt; c;</p>
<p>return 0;<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031465</guid><dc:creator><![CDATA[Blödl]]></dc:creator><pubDate>Wed, 05 Apr 2006 21:42:02 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Wed, 05 Apr 2006 21:43:02 GMT]]></title><description><![CDATA[<p>Ach scheisse ne natürlich so:</p>
<p>[cpp]<br />
int main()<br />
{<br />
int c = 10000;<br />
Test::Test(c);</p>
<p>cin &gt;&gt; c;</p>
<p>return 0;<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031467</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031467</guid><dc:creator><![CDATA[Blödl]]></dc:creator><pubDate>Wed, 05 Apr 2006 21:43:02 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Wed, 05 Apr 2006 21:56:07 GMT]]></title><description><![CDATA[<p>Blödl schrieb:</p>
<blockquote>
<pre><code class="language-cpp">int *x = new int[10000];
    for(int i = 0; i &lt; 10000; i++)
        x[i] = 123456;
</code></pre>
</blockquote>
<p>das steht so im konstruktor? dann wird dort nur eine lokale variable x initilalisiert und nicht der member x. konsequenterweise ist dieses x dann im destruktor nicht initialisiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031470</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Wed, 05 Apr 2006 21:56:07 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Wed, 05 Apr 2006 21:57:27 GMT]]></title><description><![CDATA[<p>Richtig. Danke. Bin noch Anfänger.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031471</guid><dc:creator><![CDATA[Blödl]]></dc:creator><pubDate>Wed, 05 Apr 2006 21:57:27 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Wed, 05 Apr 2006 22:08:09 GMT]]></title><description><![CDATA[<p>Trotzdem bin ich der Meinung, es wird kein Speicher reserviert.</p>
<p>Physikalischer Speicher verfügbar: 654260</p>
<p>Die Zahl bleibt immer gleich. (Wird ständig aktualisiert)</p>
<p>Auch wenn c = 1 000 000 ist also 10 Millionen Bytes reserviert werden ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031480</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031480</guid><dc:creator><![CDATA[Blödl]]></dc:creator><pubDate>Wed, 05 Apr 2006 22:08:09 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Wed, 05 Apr 2006 23:23:06 GMT]]></title><description><![CDATA[<p>vielleicht optimiert dein compiler das raus... wär grob fahrlässig, aber durchaus möglich.</p>
<p>und vertrau nich auf &quot;freier speicher&quot;, guck lieber, wieviel dein programm reserviert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031497</guid><dc:creator><![CDATA[thordk]]></dc:creator><pubDate>Wed, 05 Apr 2006 23:23:06 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Thu, 06 Apr 2006 04:37:52 GMT]]></title><description><![CDATA[<p>Blödl schrieb:</p>
<blockquote>
<p>Trotzdem bin ich der Meinung, es wird kein Speicher reserviert.</p>
<p>Physikalischer Speicher verfügbar: 654260</p>
</blockquote>
<p>Du solltest du dir eher die Working Set-Größe deines Prozesses ansehen, als den freien physischen Speicher.</p>
<blockquote>
<p>Auch wenn c = 1 000 000 ist also 10 Millionen Bytes reserviert werden ...</p>
</blockquote>
<p>Es würde mich sehr wundern, wenn ein int bei dir 10 Bytes groß wäre. Ich tippe eher auf 4.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031519</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031519</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 06 Apr 2006 04:37:52 GMT</pubDate></item><item><title><![CDATA[Reply to new &amp;amp; delete on Thu, 06 Apr 2006 08:41:52 GMT]]></title><description><![CDATA[<p>Blödl schrieb:</p>
<blockquote>
<p>Trotzdem bin ich der Meinung, es wird kein Speicher reserviert.</p>
<p>Physikalischer Speicher verfügbar: 654260</p>
<p>Die Zahl bleibt immer gleich. (Wird ständig aktualisiert)</p>
<p>Auch wenn c = 1 000 000 ist also 10 Millionen Bytes reserviert werden ...</p>
</blockquote>
<p>Also entweder kann ich nicht mehr rechnen, aber...</p>
<p>c= 1 000 000 und ein int hat 4 bytes, dann sollte doch eher bei</p>
<pre><code>x = new int[c];
</code></pre>
<p>der Speicher mit c mal sizeof(int), spricht 4 * 1000000 angelegt werden.<br />
Sind nach Adam Riese und Eva Zwerg doch 4 Mille und nicht 10?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031667</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031667</guid><dc:creator><![CDATA[Ken.Guru]]></dc:creator><pubDate>Thu, 06 Apr 2006 08:41:52 GMT</pubDate></item></channel></rss>