Clearing an array of types, how to?
BlitzMax Forums/BlitzMax Beginners Area/Clearing an array of types, how to?
| ||
I have an array Array:MyType[] I add some mytypes to it Now i want to free the memory If i do: Array = Null it is the same as looping through each element and setting them null: Local i For i = 0 to Array.length - 1 Array[i] = NULL next ? |
| ||
Yes! Except Array = Null sets the array length to 0 as well. Both will remove all the types in the array. |
| ||
To the elements within the array, the effect is the same. But with Array = null the array can't be used afterwards anymore without reinitializing it once again through new MyType[XX] |
| ||
super, thanks alot! |
| ||
So the GC will catch the fact that if the array is made null, all the pointers to types in the array should be made null also? |
| ||
Yes |
| ||
ok thanks. I'm so used to cleaning up myself I clean out the array pointers then set the array to null. |