How do you free up memory?
-
I made a simple program that uses a
for
loop to create a huge array of color vectors then converts that to an image usinguploadImage()
then displays the image, frees the image, and repeats. It displays static on the screen at about 14-15fps. I noticed free memory starts decreasing immediately when running it, I thoughtFreeimage()
would prevent that, but it makes no difference whether it's there or not. Memory decreases at 2mb per second untill it reaches 32mb then fuze4 crashes. here is the code I'm using:height = gHeight()/8 width = gWidth()/8 Array screenBuffer[height*width] Loop FillImageBuffer() imageBuffer= Uploadimage(screenBuffer,width,height,false) Drawimage (imageBuffer,0,0,8) Update() Clear() Freeimage(imageBuffer) Repeat Function FillImageBuffer() For I=0 to height*width step 1 loop c=random (255)/255 screenBuffer[I] ={c,c,c,1} Repeat Return void
I also noticed that free memory doesn't reset when going between editor and running. Nor does it reset when switching programs. The only way I can reset the free memory is to close fuze4 and reopen it. Am I doing something wrong?
-
@cshep99 this looks like a memory leak to me so I will move this topic to bug reporting. The problem seems to be specific to the uploadimage function as I am not getting the same effect with createimage
-
Mind you, congrats on getting free memory down to 32MB. I had no idea that was possible as I've never seen it drop by much :)