test memory in bmax and blitz3d

BlitzMax Forums/BlitzMax Programming/test memory in bmax and blitz3d

mongia2(Posted 2007) [#1]
i use from test a task mamager from read a memory usage

my test is simple
i load a image

freeimage
and reload a image

http://www.pippoplutoeda.altervista.org/prova_memory.zip


code bmax:

Global img_menu:timage[5]

Graphics 1024,768

interfaccia_menu()

Function interfaccia_menu()

img_menu[0]=LoadImage("interfaccia\inizio_0.jpg")

tempo = 300
inizio = 0

While Not KeyDown(key_escape)

Cls

SetColor 255,255,255

If KeyHit(key_space)

inizio = inizio + 1
If inizio > 3 Then inizio = 0

img_menu[0]=Null

img_menu[0]=LoadImage("interfaccia\inizio_"+inizio+".jpg")


EndIf

DrawImage img_menu[0] , 0 , 0


Flip

Wend

End Function


code blitz3d
dim img_menu(5)

Graphics 1024,768,0,7

interfaccia_menu()

Function interfaccia_menu()

img_menu(0)=LoadImage("interfaccia\inizio_0.jpg")

tempo = 300
inizio = 0

While Not KeyDown(1)

Cls

If KeyHit(57)

inizio = inizio + 1
If inizio > 3 Then inizio = 0

freeimage img_menu(0)

img_menu(0)=LoadImage("interfaccia\inizio_"+inizio+".jpg")


EndIf

DrawImage img_menu(0) , 0 , 0

Flip

Wend

End Function

end


mongia2(Posted 2007) [#2]
it is a exampèle for a bug in garbage collect


LarsG(Posted 2007) [#3]
try to use the codebox tags..

also, I think loading an image into the same array slot every 4 loops isn't exactly a very healthy way of doing it..
you should preload all the image into the array before the loop..

if you need to load another image later, you can branch out of the loop and load that one, when some condition is met..