lua-users home
lua-l archive

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


Agreed, the real problem is without __gc on light userdata you can never be sure when Lua has released the last pointer, so it is of limited use unless the pointer is to static memory or heap memory that will not be released until after the Lua state is closed. I'm with you, I tend to wrap C pointers in full userdata so that I can track GC correctly.

--Tim

On Jun 9, 2013, at 2:01 AM, David Heiko Kolf <david@dkolf.de> wrote:

In my opinion the term "light userdata" is a bit misleading, as I see
only a very limited value in using it for storing actual data.  You
cannot assign different metatables to each light userdata.  That means
it is later very hard to find out what was actually stored in it.  And I
don't see any way of making sure that Lua has no stray pointers left --
except by closing the entire Lua state.  So even when I need to do
memory handling in C I would store a pointer in a full userdata.