lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi:

On Fri, 15 Sept 2023 at 03:35, dormando <dormando@rydia.net> wrote:
...
> - Rarely the base objects are updated. I need the __gc() call to run on
> the old base objects soon after they are replaced to free resources.

There is your problem, NEED COLLECTION (__gc). GC is good for
tracked-memory-only resources, not that good for others ( including
objects which hold a lot of memory unbeknownst to the GC ). You may
solve this with GC tunning, but I've had some similar problems, in Lua
and other GC languages and I have ended up having to manually manage
them ( I normally have an idempotent close() method, influence by Java
naming, which I call on __gc()just in case, and now on __close() too,
as you say your objects are ocasionally updated hence neading
"destruction", you will probably be better trying to encapsulate their
managemente there.

Francisco Olarte.