[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Avoiding string duplication
- From: Sean Conner <sean@...>
- Date: Wed, 6 Nov 2019 11:45:52 -0500
It was thus said that the Great Viacheslav Usov once stated:
> On Wed, Nov 6, 2019 at 11:44 AM Chris Smith <email@example.com> wrote:
> > No, on the account that the string is still registered. A Lua string
> will be created at the start of the Lua state and that string will remain
> referenced within Lua and thus never garbage collected.
> This relies on implementation details that are not explicitly documented as
> design guarantees. To the best of my knowledge, nowhere does the
> documentation indicate that it is OK to use pointers to interned strings
> when a corresponding string value is not on the API stack. Secondly, the
> registry entry might be intentionally or mistakenly overwritten.
I use the registry to save strings, and so far, for Lua 5.1, 5.2 and 5.3,
it has worked fine for me, even in long running (that is, months of time).
If said registry entry is mistakenly overwritten, then there's a bug. If
it's intentionally overwritten, there are larger problems.
I have a string. There's a reference in the registry. I don't see the