lua-users home
lua-l archive

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


> Re: the Amped gc issue... what happens if you force a gc every frame?

This can help some problems. As you state, it definitely reduces the
unpredictability of the system.

The main problem with this ends up being the "Lua heap size"
(Not sure if there is another term for that...). Lua has to search
its entire heap to determine if the one or two (or 300) values you
have created this frame are referenced by anything. Or indeed, if
one of your 1000 values has now become un-referenced.

I've been pondering this for a while, and one solution that would
probably not be too hard, is to introduce the concept of
"const data" to the Lua GC. All of this (somehow specially marked)
const data would be placed in a separate set of structures in
Lua. When GC fired, it would simply not check this set at all.
Also, if a non-const piece of data were to reference this set,
the GC would not need to continue collecting in the const data.

With my limited knowledge of Lua, this seems easier to me than
writing a full incremental GC.

-Jonathan

----- Original Message -----
From: "Thatcher Ulrich" <tu@tulrich.com>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Sunday, August 05, 2001 2:53 PM
Subject: Lua gc in games


>
> Re: the Amped gc issue... what happens if you force a gc every frame?
> That should collect all garbage generated during that frame.  It's
> probably high total overhead, compared to doing gc periodically because
> I'm guessing the collector visits all objects on the Lua heap during gc,
> just to collect a frame's worth of garbage, but then it should probably
> keep the worst-case gc time within reason.  That is, if your Lua heap size
> is within reason...
>
> -Thatcher
>
>