[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is there a order to running finalizers of garbage collected objects?
- From: Viacheslav Usov <via.usov@...>
- Date: Wed, 28 Dec 2022 20:21:15 +0100
On Wed, Dec 28, 2022 at 4:18 AM Red Artist <redartofcode@gmail.com> wrote:
> As a follow up question, does Lua actually guarantee that if an younger object without references becomes garbage, then any older object without references MUST BE garbage too?
The collection of garbage (without finalizers) is unobservable by Lua
code and (correct) C libraries, and is observable only by the host's
memory allocator. I doubt that the manual says anything about the
unobservable collection, and any importance would only be for the
host. Given that your implementation is completely new, you should not
be worried about existing hosts, and you can actually define your own
rules here.
Now coming to the case of garbage with finalizers, one could say that
garbage with finalizers is not really garbage because it can be
resurrected during its finalization. So you should care about the
observable order of finalization (but not collection).
That said, the manual does speak of some GC behaviors that are, in
principle, also unobservable (except by the host). Since you are
thinking about a collector that is different from Lua's canonical
collector, your implementation will obviously not comply with the
manual at least here. Since you mentioned Immix, I would also mention
RC-Immix, which is a reference counting collector on top of Immix that
outperforms the latter.
Cheers,
V.