lua-users home
lua-l archive

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


If you or the implementation makes cycles involving short-lived objects
frequently, reference counting is essentially not an option without going to
much more complicated algorithms.

If this is not the case, then deferred reference counting -- i.e., don't
count references from the stack but don't free things without checking the
stack -- may be able to reduce the frequency with which one has to run a
mark-and-sweep algorithm. Combined with some form of interruptible
mark-and-sweep -- i.e., so that you can start a garbage collection while
idle but abort it if you've got real work to do -- this might suppress
enough of the issues with GC pauses to be an acceptable solution for many
(though obviously not all) applications.

There are then two overhead issues.

One is the space for the reference counts. If this is just on strings and
tables, it's probably not too bad.

The other is speed. You need the extra time needed to maintain the reference
counts to be paid for in the reduced time spent running the mark-and-sweep
algorithm.

Despite the extra space for the reference counts, it could also result in
reduced memory footprint because more memory would be recycled faster. This
could result in improved performance.

And then there's the issue of making this work with threads...

Mark