Does ClearList null references?

BlitzMax Forums/BlitzMax Beginners Area/Does ClearList null references?

ElectricBoogaloo(Posted 2010) [#1]
I can't figure out a way to test this, so might as well ask.

Type MyType
Field a
End Type

Global Object:MyType
Global ObjectList:TList=CreateList()

For n=1 to 100
Object:MyType=new MyType
ListAddLast(ObjectList,Object:MyType)
Next

ClearList(ObjectList)


At first I assumed that clearing the list would free up all those objects, but all of a sudden it occurred to me that it might not actually be doing that.
In my head, GC means that when something's no longer referenced, it gets thrown out.

But is that how BMax does things, or will there be a huge pile of random unused objects strewn around the memory?

Can't think of a way to test this, since it'd require additional references, which obviously would count against the thing I'm checking!


Brucey(Posted 2010) [#2]
As long as there is no reference to an object, it will be "thrown out" eventually.

ClearList() or list.Clear(), will remove items from the list. If those items are no longer referenced by anything else, they will be garbage collected.


ElectricBoogaloo(Posted 2010) [#3]
*phew*
Thanks!