Garbage Collection

From GMod Wiki

Jump to: navigation, search
Lua: Garbage Collection
Page white text.png Description:Explains Garbage Collection in Lua
link=User:theJ89 Original Author:theJ89
Calendar.png Created:2nd December 2006

Garbage collection refers to the set of algorithms used to automatically delete variables which are no longer reachable, i.e., the variables can no longer be accessed by the program.

Whenever Lua's garbage collector is run, it determines which objects are accessible, and the remaining objects are automatically destroyed.

The __gc metamethod is part of an object's metatable and cannot be executed directly - it is called when the garbage collector runs, and determines the object to which the metamethod belongs is unreachable.

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox