How do I release an object?

BlitzMax Forums/BlitzMax Programming/How do I release an object?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Release goes hand-in-hand with HandleFromObject. HandleFromObject increases the internal reference counter and returns an integer handle to an object. you can use this integer handle with HandleToObject to convert it back into an object. unlike HandleFromObject, HandleToObject does _not_ affect the reference counter. if all object references to the object are set to null the object will still not be garbage collected until Release is called on the integer handle. this works at all strict levels.
SuperStrict
Framework BRL.Blitz

Type test
	Field i:Int=15
EndType

Local temp:test=New test ' reference count is 1
Local hTemp:Int=HandleFromObject(temp) ' reference count is now 2

temp=Null ' reference count is still 1
DebugLog(test(HandleToObject(hTemp)).i)
Release(hTemp) ' references are now 0