lua-users home
lua-l archive

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

> I was disappointed that the Lua SP&E paper didn't say much about Lua's
> garbage collection.  I would like to have my C code allocate objects
> of type userdata that get managed by Lua's garbage collector, but from
> the documentation I can't figure out how to do that.  Is it possible?

Not now. Userdatas (void *) are considered values, like numbers, so they are 
not allocated and therefore not collected. This will change in the next
version (3.0; an alpha version is coming very soon). Userdata will handle
any binary data, not only pointers. They will be objects, not values, and
therefore will be collected (and there will be a "fallback" to signal this).

-- Roberto