lua-users home
lua-l archive

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


Another thing to try with respect to a reference counting GC is to only
count references from other heap objects and not from the stack. This saves
a fair amount of book keeping at the expense of delaying collection a bit.
When an object's count goes to zero, you put it on a list of objects whose
count is zero. You can then periodically do a minor GC wherein you clear the
mark flags for all objects on the zero-count list, mark everything reachable
from any of the stacks, and then collect any objects that remain unmarked.
This involves two passes over the zero-count list and you can use either of
those passes to remove objects whose count is no longer zero. The tradeoff
is less reference count manipulation for slightly delayed collection and
extra work if there are a significant number of objects that are only
referenced from the stack.

On the other hand, it isn't clear that this would work particularly more
effectively than a simple generational scheme. It depends on the data usage
pattern.

Mark