lua-users home
lua-l archive

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


> Oh, thanks, didn't know that (should it be mentioned in the Manual?)

The manual hints about that:

  Garbage userdata with a field @id{__gc} in their metatables are not
  collected immediately by the garbage collector.
  Instead, [...]

But it could be more explicit.


> And why Luiz had different results then?

A natural (non forced) collection occurred. Notice the output:

  Lua 5.1.2  Copyright (C) 1994-2007 Lua.org, PUC-Rio
  1:      20.8818359375
  2:inside __gc
          1044.9306640625
  3:      17.99609375

The "inside __gc" message appeared just after the "2:", before the
call to collectgarbage"collect". So, that call forced a second collection,
which then removed the userdata.

-- Roberto