[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Garbage collection and Lua 4.1 Alpha
- From: "Jonathan Branam" <sspeare@...>
- Date: Sun, 5 Aug 2001 16:00:44 -0700
----- Original Message -----
From: "Josh Jensen" <firstname.lastname@example.org>
To: "Multiple recipients of list" <email@example.com>
Sent: Friday, August 03, 2001 4:07 PM
Subject: Garbage collection and Lua 4.1 Alpha
> Yep, here we go again.
It never ends... :>
> The garbage collection update for my title is over 60 milliseconds.
> Since the frame rate is high, 60 milliseconds causes a very large,
> unacceptable blip in the frame rate.
> So, my question is this. Since Lua doesn't have an incremental garbage
> collector, would it be possible to patch Lua to free the memory for nil
> objects as they become nil? This would be an acceptable alternative to
> me. It's been too long since I dug deep into the Lua internals to know
> if this is possible.
I explored this briefly. What I realized was that there are many, many
cases which "de-reference" a piece of data. Catching all of these is
- Passing the end of a block removes all local variables
- Passing out of a function removes all function parameters
- Returning from a function, and not using all the return values
- Anytime lua_settop() or lua_pop() is called from C to pop the stack.
- Assigning an existing variable to a new value
- lua_unref() from C
- GC of a table
- GC of a function (I think at least the upvalues become dereferenced)
However, I believe you could add a simple function/VM instruction (not
sure which is really required) to de-allocate values at will.
What this means is that you have to go back and find all times in the
script which would cause a de-allocation and put this instruction there.
Also, if you made an error in de-allocation, and somewhere there is a
reference to that value, then you are in trouble. Having Lua verify
that nothing references this value is the same cost as the GC pass
(well, a little less).
> Any other ideas would be great, too.
See my other message today under the title "Re: Lua gc in games."
If you can create a concept of "const data" in Lua, and if most
of your data is const, which is likely, then the GC can be run
more often, on a much smaller data set.
> Joshua Jensen
> Amped: Freestyle Snowboarding