[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua userdata and garbage collection
- From: bil til <biltil52@...>
- Date: Sat, 25 Nov 2023 17:14:32 +0100
You should put a reference to each list item in the Lua registry, then
it will NOT be garbage collected.
See e. g. Roberto's Book "Programming in Lua", chapter "Thread and
States", "Multiple states", page 287 top, how to protect threads
against ill garbage collection.
Side remark: Creating TOO much userdata items is quite a "waste of
memory". If you have not "myriads of memory", maybe better use
userdata only for the "list organizer", and allow access to the list
items only by the userdata fuctions you present for this "list
organizer" - this sounds smarter I think, especially if you would
allow the list a somehow "unlimited" amount of elements (of course I
do not know your application - maybe better describe a bit the
purpose, for what you want to use such a list organisation..).