[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [BUG] table will be garbage collected multiple times
- From: Francisco Olarte <folarte@...>
- Date: Sun, 18 Nov 2018 12:07:11 +0100
On Sun, Nov 18, 2018 at 9:51 AM Gregor Burghard <email@example.com> wrote:
> here is a bug for Lua >= 5.3.0:
> When the finalizer method of a table resets the metatable of the same
> table, it will not be deleted after finalization. That means the table
> still exists and will be garbage collected again.
A more knowledgeable person may be give better details, but given
<<You mark an object for finalization when you set its metatable and
the metatable has a field indexed by the string "__gc". >>
and a bit later..
<<Moreover, if the finalizer marks a finalizing object for
finalization again, its finalizer will be called again in the next
cycle where the object is unreachable>>
Seems like documented / expected behaviour to me ( a bit weird, but I
assume there is a reason, I can think of a couple of them ).