Timer memory leak?

BlitzMax Forums/BlitzMax GUI Programming/Timer memory leak?

I've come across a situation where memory use as reported by GCMemAlloced() is increasing with each timer tick. I've stripped my code back to bare bones and the problem still occurs (as below).

I'm running in OS X 10.4.9 (Intel iMac) with latest updates and I've just done a syncmods and rebuild on Max.

I must be doing something very simple wrong, but can't see what it is?

Thanks for any help

David De Candia

Strict

Type TApp
	
	Field Window:TGadget
	Field Timer:TTimer
			
	Method OnEvent(event:TEvent)
			
		'	if event.id = EVENT_TIMERTICK DebugLog "Tick"
				
		If event.id = EVENT_WINDOWCLOSE
			Cleanup
			End
		EndIf
			
		SetStatusText Window, GCMemAlloced()
					
	End Method

	Method Cleanup()
		
		StopTimer(Timer)
	
		RemoveHook EmitEventHook,EventHook
			
	End Method 'Cleanup
	
	Function EventHook:Object(id,data:Object,context:Object)
		
		Local	event:TEvent
		Local	app:TApp
		
		'	CAST THE DATA TO AN EVENT
		event = TEvent(data)
	
		'	CAST THE CONTEXT TO MY APP 
		app = TApp(context)
		
		'	RUN ON_EVENT
		If app And event Then app.OnEvent(event)	
	
	End Function
	
	Method Create(s_app_text:String)
							
		'	Create the main window
		Window = CreateWindow("test ticker",0,0,640,480,Null)
		
		'	Create a timer to tick once every n seconds
		Timer = CreateTimer((1.0/0.1)) 	' 1/15
	
		'	Watch for user events
		AddHook EmitEventHook,EventHook,Self
		
				
	End Method
	
End Type

'----------------------
'     *** Main ***
'-----------------------

	Try
		Local app:TApp = New TApp
		
		app.Create("test")
					
		'	Wait for an event, and process it 
		While True
		  WaitEvent()
		Wend
	
	'	Catch and print any exceptions
	Catch exception:Object
		DebugLog exception.ToString()
	End Try

End



The mem allocated doesnot keep going up, it goes up, then at some point the memory is GC'd then it drops back down again, then it builds up etc

This is normal

(smiles) Whoops!

I've obviously got a leak elsewhere in my app then, as it keeps on spiralling up and up without resetting.

I didn't sit on the bare-bones version long enough to notice it was resetting and thus thought the bug was still there - my mistake - sorry.