This is worth knowing...

BlitzMax Forums/BlitzMax Programming/This is worth knowing...

OK, I know this isn't the best OOP code. But basically if a method of a type calls an external function that kills the global instance of the type, the type won't get killed until the method exits. This can be seen by running the following code. The print line still works. However, uncomment t.More() and run in debug mode and you will get a null object error.

Strict
Type TTest
	Method Bang()
		KillTest()
		Print "hello"
	End Method
	
	Method More()
		Print "more"
	End Method
End Type

Global t:TTest = New TTest

t.Bang()
't.more() 'uncomment this line

Function KillTest()
	t = Null
End Function

Does anyone know if the garbage collection code *always* works like this in this sort of situation of could it free up the type before the print occurs, or could it leave the type hanging around for a bit longer so t.more() works?

Thanks.