lua-users home
lua-l archive

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


> I keep seeing references to Lua's GC and how to "make it 
> better", but I
> always feel like I'm only hearing part of the conversation.  
> Is there a
> summary of Lua's GC and what issues it has related to games in
> particular?

Basically Lua has mark and sweep GC. ie. it goes through and tags everything
that references something. Anything left is redundant and swept away
(collected). This is done in one pass so you can imagine the implications if
you are trying to do it in a frame and you have a lot of objects. Obvious
solution to this is to try and create as few objects as possible (so they
wont need collecting when they die) and divide up the GC time over several
frames (incremental GC) or prioritise which objects are more likely to need
collecting and do those more often (eg. younger objects, hence generational
GC). (sorry if you knew all that :-) Noone has really presented an
alternative to the Lua GC yet but a few have dabble and maybe done their
own. Currently the generational GC is favoured by the Lua team.

References:
http://lua-users.org/wiki/GarbageCollection
http://lua-users.org/wiki/OptimisingGarbageCollection
http://lua-users.org/cgi-bin/namazu.cgi?query=garbage+collection&sort=score&;
idxname=lua-l&max=20