> So - as far as memory usage goes, is it correct to say that if a string
> is not reachable by any means, weak table or otherwise, it will be > collected?
Yes, eventually, probably.
Sorry I cannot be more precise than that, but that
is the way it is.
Lua does not aggressively garbage collect strings.
It also does not aggressively garbage collect table keys. So they might
hang about for a while.
Lightuserdata are like numbers: they don't actually
take up any space because they are entirely contained within the
"reference". (The reference takes up space, but no additional space
is taken up by the object.) This also applies to nil, true
and false.
If you had an id whose value could be converted easily
into something that could be cast to (void*), you would
be better off using a lightuserdata, provided that you could
guarantee that no other "type" of lightuserdata might
have the same value. For example, if your id is actually the address
of a foreign object, and all your lightuserdata are addresses
of some object or another, then you could use a lightuserdata instead of converting the id to a string. That would
reduce your memory utilisation and save on garbage collection
time.