I have a full userdata in Lua module written in C. The userdata has __gc()
metamethod, which is called by garbage collector. Does lua interpreter free userdata memory after __gc()
call, or do I have to free()
it inside __gc()
?
views:
302answers:
1
+4
A:
You should not free the memory, as you didn't malloc() it yourself; Lua does both for you. In fact, the memory isn't even collected in the same garbage-collection cycle, as section 2.10.1 in the Lua 5.1 reference manual explains.
Jan de Vos
2008-10-21 09:32:55