memory leak

Blitz3D Forums/Blitz3D Programming/memory leak

dena(Posted 2005) [#1]
Hello everyone:
Am having a memory leak on a very simple piece of code that needs to run for several hours at a time. when I run the code and watch the task manager as it runs, my PF Usage rises slowly and steadily.

What I am trying to do is have 4 letters, G, A, T, and C randomly cycle, sort of like a counter. It works like I want it to, except for the leak. I am doing it by randomly loading little image files, but if there is a more efficient way to do this, I would love to know as well.

Here is the code:

+++++++++++++++++++++++++++++++++++++++
Graphics 640,480,16
SetBuffer BackBuffer()
SeedRnd MilliSecs()

;outTimer = MilliSecs() + (10000)

;Global TimerState = 0

While Not KeyHit(1)

;If MilliSecs > outTimer
; outTimer = MilliSecs() + (10000)
; TimerState = 1
; If TimerState = 1
; Outcome=LoadImage ("outcome_" + Rand(1,10) + ".png")
; DrawImage Outcome,180,100
; FreeImage Outcome
; outTimer = MilliSecs() + (10000)
; ;TimerState = 0
; Else TimerState = 0
; EndIf
;EndIf



DNA=LoadImage ("GTAC_" + Rand(1,4) + ".png")
ScaleImage DNA,1.2,1.2
DrawImage DNA,100,100
;Delay 150
FreeImage DNA
Flip



DNA1=LoadImage ("GTAC_" + Rand(1,4) + ".png")
ScaleImage DNA1,1.2,1.2
DrawImage DNA1,132,100
;Delay 90
FreeImage DNA1
Flip


DNA2=LoadImage ("GTAC_" + Rand(1,4) + ".png")
ScaleImage DNA2,1.2,1.2
DrawImage DNA2,116,100
;Delay 120
FreeImage DNA2
Flip


DNA3=LoadImage ("GTAC_" + Rand(1,4) + ".png")
ScaleImage DNA3,1.2,1.2
DrawImage DNA3,148,100
;Delay 100
FreeImage DNA3
Flip
Cls

Equals=LoadImage ("equals.png")
MaskImage Equals,255,255,255
DrawImage Equals,164,102

;Cls

Wend

End

++++++++++++++++++++++++++++++++++++


Ross C(Posted 2005) [#2]
Equals=LoadImage ("equals.png")
MaskImage Equals,255,255,255
DrawImage Equals,164,102


Your loading that image every frame and not freeing it. :o)


dena(Posted 2005) [#3]
duh
thanks Ross C!!


Ross C(Posted 2005) [#4]
np's :D


jhocking(Posted 2005) [#5]
What is this program for anyway? I mean, randomly generated DNA isn't particularly useful in my mind.


TomToad(Posted 2005) [#6]
Wouldn't it be better to do something like this?

Dim DNA(4)
Graphics 640,480,16
SetBuffer BackBuffer()
SeedRnd MilliSecs()

Equals = loadimage("epuals.png")

For t = 1 to 4
 DNA(t-1) = LoadImage("GTAC_"+t+".png")
Next

While Not KeyHit(1)
 For t = 0 to 3
  DrawImage DNA(Rand(0,3)),100+t*16,100
 Next
 MaskImage Equals,255,255,255
 DrawImage Equals,164,102
Wend