VS2012-Compiler Seltsame Probleme bei der Speicherfreigabe

Ich habe ein seltsames Problem mit dem VS2012-Compiler, das in GCC nicht angezeigt zu werden scheint. Das Aufheben der Zuweisung dauert weniger Sekunden als Minuten. Hat jemand einen Input dazu? Das schrittweise Debuggen zeigt einen merklichen Stillstand bei Aufrufen von RtlpCollectFreeBlocks (). Ich habe dieses Problem sowohl im Debug- als auch im Release-Modus. Ich verwende Windows 7 32-Bit, habe aber auf 64-Bit 7 das gleiche Problem.

#include "stdafx.h"
#include <iostream>
#include <stdint.h>
#include <cstdlib>

#define SIZE 500000

using namespace std;

typedef struct
{
    uint32_t* thing1;
}collection;

/*
 * VS2012 compiler used.
 * Scenarios: 
 *  1) Don't allocate thing1. Program runs poorly.
 *  2) Allocate thing1 but don't delete it. Program runs awesome.
 *  3) Allocate thing1 and delete it. Program runs poorly.
 * 
 * Debug or Release mode does not affect outcome. GCC's compiler is fine.
 */
int _tmain(int argc, _TCHAR* argv[])
{
    collection ** colArray = new collection*[SIZE];

    for(int i=0;i<SIZE;i++)
    {
        collection * mine = new collection;
        mine->thing1 = new uint32_t; // Allocating without freeing runs fine. Either A) don't allocate or B) allocate and delete to make it run slow.
        colArray[i] = mine;
    }

    cout<<"Done with assignment\n";

    for(int i=0;i<SIZE;i++)
    {
        delete(colArray[i]->thing1); // delete makes it run poorly.
        delete(colArray[i]);

        if(i > 0 && i%100000 == 0)
        {
            cout<<"100 thousand deleted\n";
        }
    }
    delete [] colArray;

    cout << "Done!\n";
    int x;
    cin>>x;
}

Antworten auf die Frage(1)

Ihre Antwort auf die Frage