I have a question regarding array of images. In the following code, I load a number of images from a folder into an array. But if I reload them, I was expecting to have the program use the same amount of memory as before, at least about the same after a while and the memory cleanup had occured.
But while its the same images loaded each time, the program uses everything from around 90mb to 400bm, which doesn't seem ideal, and I would like to have it use about the same with each reload of the images.
It likely that there is something I am missing about using array to store images, and how the memory clean up works. And if so, it would be nice, if someone could point me in the right direction of how its done properly.
But while its the same images loaded each time, the program uses everything from around 90mb to 400bm, which doesn't seem ideal, and I would like to have it use about the same with each reload of the images.
Framework BRL.GLMax2D Import BRL.JPGLoader Import BRL.EventQueue Import BRL.Retro Graphics 640,480 Global picImg:TImage[500] Global picCount:Int = loadPictures("picturefolder") Repeat Select WaitEvent() Case EVENT_KEYDOWN Local key:Int = EventData() If key = KEY_SPACE Then picCount = loadPictures("picturefolder") End If Case EVENT_APPTERMINATE EndGraphics End End Select Flip Forever Function loadPictures:Int(dir:String) Local i:Int = 0 Local folder:Int = ReadDir(dir) Local file:String Repeat file=NextFile(folder) If (file <> ".") And (file <> "..") If file <> "Thumbs.db" Then Local fullPath:String=RealPath(dir+"/"+file) If Lower(Right(fullpath,3)) = "jpg" Then picImg[i] = LoadImage(fullpath) i :+ 1 End If End If End If Until (file=Null) CloseDir folder Return i End Function
It likely that there is something I am missing about using array to store images, and how the memory clean up works. And if so, it would be nice, if someone could point me in the right direction of how its done properly.