lua-users home
lua-l archive

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


> Lua garbage collects strings.
> [...]
> -- However, there is some persistence

The persistence is not related to the strings themselves, but to
the string hash (used to coalesce identical strings) and the string
buffer (used to concatenate strings). During garbage collection, those
structures have their size halved when they are too big, so it takes
some collections to reduce a really oversized structure to its original
size.


>  Lua does not aggressively garbage collect strings. It also does not
>  aggressively garbage collect table keys. So they might hang about for
>  a while.

During a GC cycle, Lua 5.0 collects all strings that are not reachable
by the program. It also collects any object left as a key of a dead
entry (that is, which associated value is nil)...  Except for weak table
string keys.  (This exception is actually unnecessary and could be
considered a bug, I guess.)

-- Roberto