[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Incremental garbage collection coming to Lua soon?
- From: Mark Hamburg <mhamburg@...>
- Date: Thu, 31 Jul 2003 10:48:28 -0700
on 7/31/03 12:06 AM, David Jeske at jeske@chat.net wrote:
> On Wed, Jul 30, 2003 at 03:57:13PM -0700, Mark Hamburg wrote:
>> If going this route, I would recommend only counting references from tables
>> and closures and avoid counting references from the stack together with a
>> zero-ref-count list that lists objects that either have no references or are
>> only referenced from the stack. Dealing with refcounts while storing to
>> tables is probably a relatively small hit and the stack is already scannable
>> for the existing GC.
>
> This has the drawback that it makes finalizer semantics less
> immediate, but I agree it does have the potential for increased
> performance.
I think if you want to depend on finalizer semantics then you want something
other than automatic memory management. You can, however, use automatic
memory management as a useful fallback. For example, if you have an object
that represents an open file, make it handle the case where the file is
closed -- potentially just by signaling an error -- and provide an explicit
close operation. The finalizer then has the job not of closing the file but
of closing it if it didn't get explicitly closed.
One could also manually trigger a collection of the "zero-reference-count"
tables if it was important to recover some other resource rapidly.
Mark