Just like any other object, they are eligible for garbage collection when there is no more strong references to that object. I say eligible because, the actual garbage collection process is not guaranteed to occur immediately upon the last strong reference no longer existing. Lua only guarantees that process may happen at any time following the loss of the last reference to the object. But Lua may also decide to trigger a garbage collection process at any point during your code’s execution because it deems it is running low on memory, for instance.
1 Like