but the error only occurs when i run the loops over X times...
I run 100-1000 loops per pixel on the map, its a shitload of loops, many many millions of them...
is there a way to clear the memory used after each iteration? (besides the array)
heres the code in question (a metal handler):
Code: Select all
for (int a = 0; a != 20; a++)
{
TempMetal = 0;
for (int i = 0; i != TotalCells; i++)
{
if (MexArrayB[i] > TempMetal)
{
TempMetal = MexArrayB[i];
coordx = i%MetalMapWidth;
coordy = i/MetalMapWidth;
}
}
if (TempMetal)
{
for (int myx = coordx - XtractorRadius; myx != coordx + XtractorRadius; myx++)
{
if (myx >= 0 && myx <= MetalMapWidth)
{
for (int myy = coordy - XtractorRadius; myy != coordy + XtractorRadius; myy++)
{
if (myy >= 0 && myy <= MetalMapHeight && ((coordx - myx)*(coordx - myx) + (coordy - myy)*(coordy - myy)) <= XtractorRadius*XtractorRadius)
{
MexArrayB[myy * MetalMapWidth + myx] = 0;
}
}
}
}
}
MexArrayA[coordy * MetalMapWidth + coordx] = TempMetal;
}
It seems to me that the program is spawning so many myx and myys that it takes up all the memory...