..Type data freeing..

BlitzMax Forums/BlitzMax Programming/..Type data freeing..

Naughty Alien(Posted 2009) [#1]
..what would be best/most elegant way to free data in entire Type collection with GC? What would be the proper way of doing same thing but only for specific data inside type collection, not entire data stored in types?


plash(Posted 2009) [#2]
Set any variables in question to Null.


_Skully(Posted 2009) [#3]
Well, not exactly..

for example, if you have type references that are also attached to Tlists they will not be disposed of... you just need to think.. is the content of this type referenced anywhere else... if not... ya, just set the type reference to null or remove it from the Tlist and everything else will go with it.


Naughty Alien(Posted 2009) [#4]
..what will happen with fields that representing some other Type structure..like..

Type TBlock_01
global Block_01_List:TList
a:int
b:int
c:TBlock_02
End Type

Type TBlock_02
Global Block_02_List:TList
e:int
f:int
g:TBlock_03
End Type


so if i say 'Something.c = null' whats going to happen with fields within TBlock_02 and TBlock_03 ?


Gabriel(Posted 2009) [#5]
That will depend on whether there are any other references to the specific TBlock_02 and TBlock_03 objects in question.


_Skully(Posted 2009) [#6]
TBlock_02 will be collected and The Block_02_List TList would be lost meaning anything referenced by that TList would be lost if no other references exist, and the TBlock_03 would be collected if not null


Gabriel(Posted 2009) [#7]
The Block_02_List TList would be lost meaning anything referenced by that TList would be lost if no other references exist

No it wouldn't. Globals are static, they do not belong to a type instance, so they will not be affected by the GC collecting instances of that type.


_Skully(Posted 2009) [#8]
Oh yes quite correct