Free

Category: Runtime Helpers

Back to System Functions


Signature

Free(objectValue)

Returns

Void

Description

Releases a user-defined object that was previously created with New.

Use this for values declared with Dim ... As TypeName and then assigned from New TypeName. This is not used for runtime asset handles such as images, sprites, or fonts. Those still use FreeImage, FreeSprite, and FreeFont.

Free releases only that one object instance. If the object contains fields that refer to other objects created with New, free those nested objects separately first if needed.

After calling Free, do not access fields through that value again unless you assign a new object to it first.

Example

Type Player Field Score As Integer End Type Dim player As Player player = New Player player.Score = 100 Free(player)