Something eats my memory

BlitzMax Forums/BlitzMax Beginners Area/Something eats my memory

I can't understand this at all.
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?

Doesnt eat memory here, using this code plus your unchanged code:

Graphics 1024,768

Stars.Create(100)

While Not KeyHit(KEY_ESCAPE)

	Stars.Update()
	Stars.Draw()
	
	SetColor 255,255,255
	DrawText MemAlloced(),0,0

	Flip
	Cls
	FlushMem
Wend


Problem solved.
I called flushmem inside a function in a type, that was called by a function in another type... :P
(It was called by a state inside my game state engine http://www.blitzbasic.com/codearcs/codearcs.php?code=1468 )

How come I can't flush the memory wherever I want?

Check last post

Thank you both for the help. It all works now. :)