lua-users home
lua-l archive

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


In message <54193115.20031029154124@ngs.ru>, Antero Vipunen writes:
> Hello All,
> 
> I have a strange problem with GC.
> I assigned __gc metamaethod for my objects to trace gcollection
> and discovered that when i create luathreads using lua_newthread, run
> some scripts in them and then call lua_setgctreshold(0), all my
> objects become gc'ed except created in thread, that was created last.
> 
> Is it a bug or special feature?

Are you creating your objects in a loop like this:

for i=1,1000 do
  object = create()
end

?

If so the last object created will still be reachable via the global
variable 'object', so it won't be reclaimed when you force a GC.

If this is what is happening, then assign nil to the variable, then GC.

Why do you care exactly when the objects are reclaimed by the way?

David Jones