lua-users home
lua-l archive

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

You have to understand that there is no difference between a chunk and
a function. A registered global function is merely a chunk that has
been assigned as a value in the global table.

The data comprising a chunk (its bytecode, and other information) will
be kept in memory for as long as there is a reference to it, such as
it existing in the global table or in a local variable for a function
that is in scope. Once there are no more references, it will be
garbage collected, and its memory will be freed. Now, if the chunk set
a bunch of global variables and called a bunch of functions when it
was executed, those changes will not be undone when the chunk itself
is garbage collected.