[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua and C - misc questions
- From: Ben Sunshine-Hill <sneftel@...>
- Date: Sat, 20 Aug 2005 19:23:24 -0700
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.