I use HeapAlloc to alloc a huge amount of memory, like 400 MB, but when i check the Memory Usage of my program it really uses like 1 GB.
//configuraciones.h
#define ANCHO_MUNDO 5000
#define ALTO_MUNDO 5000
//unidades.cpp
unidad* unidades_memoria = (unidad*)HeapAlloc(heap, //User Heap
NULL,ANCHO_MUNDO*ALTO_MUNDO*sizeof unidad);
unidad*** unidades = new unidad**[ANCHO_MUNDO]; //Default Heap
for(int i = 0; i < ANCHO_MUNDO;i++)
unidades[i] = new unidad*[ALTO_MUNDO];
unidad* actual = unidades_memoria;
unsigned int id = 0;
I debuged my program and I realized that the memory usage icreases when this code is executed
for (int y = 0; y < ALTO_MUNDO;y++)
for (int x = 0; x < ANCHO_MUNDO;x++)
{
unidades[x][y] = actual;
actual++;
unidades[x][y]->id = id;
id++;
unidades[x][y]->dueño = 0;
memset(&unidades[x][y]->addr,0,sizeof(unidades[x][y]->addr));
}
Why is this happening??