lua-users home
lua-l archive

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


The current garbage collector is non-moving, and it is hard to imagine this changing. Garbage collection might happen at virtually any moment; if strings and userdata could move around unexpectedly, it would severely complicate the C interface.

On 2-Aug-04, at 4:10 AM, Michael Roth wrote:

Is the pointer returned by lua_newuserdata() a constant one or exists a
possibility that the memory block will be moved by lua and the address
of the returned memory block change during garbage collection?

I plan to use a C-pointer stored outside the lua context pointing to a
memory block returned by lua_newuserdata().

I know already, if there aren't any references from lua to the userdata
object the memory block will be collected and my pointer become invalid.