Mem leack in my particle emittor code.

BlitzMax Forums/BlitzMax Beginners Area/Mem leack in my particle emittor code.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Strict

Graphics 1024,768,16,0

Global particle_count:Int = 0
Global maxparticles:Int = 100
Global direction:Int = Rand(0,360)
Global mx:Int, my:Int

SeedRnd MilliSecs()

SetMaskColor 255,0,255

AutoMidHandle True

Global particles:TImage = LoadImage("particle.png",MASKEDIMAGE)

SetImageFont Null


Global particle_list:TList = CreateList()

Type particle

	Field x:Int, y:Int, d:Int, s:Int
	
		Function create()
		
			If MouseDown(	KEY_MOUSELEFT)
			
				Local p:particle = New particle
				p.x = mx
				p.y = my
				p.d = Rand(0,360)
				p.s = Rand(4,20)
				ListAddLast particle_list,(p)
			
			EndIf
			
		End Function
		
		Method draw()
		
			For Local p:particle = EachIn particle_list
			
				DrawImage particles,p.x,p.y,0
				
			Next
			
		End Method
		
		Function update()
			
						
			For Local p:particle = EachIn particle_list
			
				p.x = Sin(p.d) * p.s + p.x
				p.y = Cos(p.d) * p.s + p.y
				
			Next
			
		End Function
		
		Function destroy()
		
			For Local p:particle = EachIn particle_list
			
				If p.x > 1030 Or p.x < -2
				
					p = Null
					
				EndIf
				
				If p.y > 780 Or p.y < -2
				
					p = Null
					
				EndIf
				
			Next
				
		End Function
							
End Type

		

Repeat

	Cls
		
		mx = MouseX()
		my = MouseY()
		
		particle.create()
	
			For Local p:particle = EachIn particle_list
			
				p.draw()
			
			Next
		
		particle.update()
		particle.destroy()
				
	FlushMem
	
	Flip
	
	
		
Until KeyHit(KEY_ESCAPE)


I have a destroy function in my type. I call it then call flushmem but it still seems that it doesnt release the or destroy instances.

Any ideas?