lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


The garbage collector in 5.4 implements a generational mode. If an object survives the minor collections it may take a very, very long time before its __gc metamethod gets called after is becomes inaccessible, especially if your program mostly creates short lived objects. This makes __gc less useful as a poor man's RAII replacement. 

The new "toclose" feature is much more useful to release resources and unlock locks in a timely matter.

(If you use finalizers in such a way that the point at which it is run matters much your code is very likely buggy for other reasons as well)