lua-users home
lua-l archive

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

Dňa st 28. 9. 2022, 9:41 bil til <> napísal(a):
I cannot really
recognize, whether local variables are destroyed by gc, or whether
they exist on stack and are destroyed "automatically" and end of their

Variables are not "destroyed by GC", objects in memory (that the variables refer to) are. When the objects in memory (tables, strings, userdata, ...) are no longer accessible from anywhere (e.g. local variables), they are eligible for garbage collection and might be cleaned up at some later point in time, at which point their __gc would be called.

__close is a way to deterministically execute some cleanup when a variable goes out of scope.