[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Strings and GC - was RE: Using full userdata as table index?
- From: "Kevin Baca" <lualist@...>
- Date: Tue, 10 Feb 2004 15:22:23 -0800
> Wouldn't a better solution have been to generate the same
> userdata for each id? Or alternatively, use a number or
> lightuserdata instead of a character string?
On the C side the ids are not strings. They are more of a GUID, but
they are larger than a pointer so can't be easily converted to a
lightuserdata or a number.
Also, the bookkeeping overhead required for keeping track of the
userdatas that were generated (so I could always return the same
userdata) was something I wanted to avoid.
> Lua garbage collects strings.
Forgive me, but why when a string is used as a key for a weak-keyed
table is it not GC'd?
s = "s"
t = setmetatable( {}, { __mode="k"} )
t[s] = {}
=t[s]
table: 0112A6D8
s = nil
collectgarbage()
=t["s"]
table: 0112A6D8
-Kevin