I can't understand this at all.
Here is some source:
I have a big problem with the Update() function. It keeps eating memory.
The value returned by MemAlloced() keeps rising and doesn't slow down at all.
And as you can see I dont do anything else than looping through a list.
If I comment out for ... next, or dont call Update() at all, then everything is fine.
I also tried to add s = Null after the for loop but that didn't help.
I call FlushMem every frame, but it doesn't help at all.
Anyone have a clue why it keeps eating memory?
Here is some source:
Type Stars Global starlist:TList Function Create( num:Int ) If Not starlist Then starlist = CreateList() For Local i = 0 Until num Local s:Stars = New Stars s.x = Rand( 0, GraphicsWidth() ) s.y = Rand( 0, GraphicsHeight() ) s.speed = 0.1+Rnd(2) starlist.addlast(s) Next EndFunction Function remove() If starlist Then starlist.clear() EndFunction Function draw() Local s:Stars For s = EachIn starlist s.d() Next EndFunction Function update() Local s:Stars For s = EachIn starlist 's.u() ' Commented out. Not part of the problem... Next EndFunction Field x:Float, y:Float, speed:Float Method u() y:+speed If y > 600 Then y = 0 x = Rand(0, 800 ) EndIf EndMethod Method d() Plot x,y EndMethod EndType
I have a big problem with the Update() function. It keeps eating memory.
The value returned by MemAlloced() keeps rising and doesn't slow down at all.
And as you can see I dont do anything else than looping through a list.
If I comment out for ... next, or dont call Update() at all, then everything is fine.
I also tried to add s = Null after the for loop but that didn't help.
I call FlushMem every frame, but it doesn't help at all.
Anyone have a clue why it keeps eating memory?