force GCCollect, good practice?

BlitzMax Forums/BlitzMax Beginners Area/force GCCollect, good practice?

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.

I'm gonna go with TaskMaster on this one. It seems that if an Type contains a Field Tlist (And that is the only reference to it) when the Type is nulled, the List lives on.

try this and then unrem the 'clearlist' line.

Type Tmemtest
	Field FooList:TList = CreateList()
	Method New()
		For x = 1 To 10
			ListAddLast Foolist , New Tfoo
		Next

	End Method
End Type

Type Tfoo
	Field big:Int[100]	
	Method New()
		For x = 0 To Len(big)-1
			big[x] = x
		Next
	End Method
End Type

Local test:TList = CreateList()



Print "done creating"

Graphics 640,480
Repeat
	
	Local mem:Int = GCMemAlloced()
	SetColor 0,0,255
	DrawText "GCMemAlloced()="+mem, 0,0
	DrawText " UP to add, DOWN to remove",0,20
	DrawText CountList(test),0,40
	
	SetColor 255,255,0
	DrawRect (0,197,(mem*0.001)+6 ,46)

	SetColor 255,0,0
	DrawRect (3,200,mem*0.001 ,40)
	
	If KeyDown(KEY_UP)
		ListAddLast test, New Tmemtest
	EndIf
	
	If KeyDown(KEY_DOWN)
		If Not test.isEmpty()
			Local a:Tmemtest = Tmemtest(test.last())
			'ClearList(a.FooList)   ' <<<<<<<< <<<< < < <  UNREM this line to test
			ListRemove test , a
			a = Null
		EndIf
	EndIf
	Flip
	Cls
Until AppTerminate() Or KeyDown(KEY_ESCAPE)