Values in TMaps - Ref Counted?

BlitzMax Forums/BlitzMax Programming/Values in TMaps - Ref Counted?

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

please excuse the unruly code here but when you null out the Object the Tmap seems to get cleared. not sure if htis answers your Q but hey, it's late & I'm tired :)


Type Tmemtest
	Field FooMap:Tmap = CreateMap()
	Method New()
		For x = 1 To 10
			Local k:Tkey = New Tkey
			k.n = x
			MapInsert(FooMap , k , New Tfoo )
		Next

	End Method
End Type


Type Tkey
	Field n:Int
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())
			' ClearMap(a.FooMap)   ' <<<<<<<< <<<< < < <  UNREM this line to test
			ListRemove test , a
			a = Null
		EndIf
	EndIf
	Flip
	Cls
Until AppTerminate() Or KeyDown(KEY_ESCAPE)