lua-users home
lua-l archive

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


> I've just met this interesting behavior while writing my Box2d
> wrapper. I don't know if it's a bug or not but Lua 5.1.4 avoids GC
> steps while running a __gc metamethod.

The next example calls collectgarbage inside a __gc metamethod without
any problems (at least in my machine):

-------------------------------
u = newproxy(true)
getmetatable(u).__gc = function (o)
  print("start gc", o)
  collectgarbage()
  print("end gc", o)
end

for i = 1, 10 do
  u = newproxy(u)
  print("creating", u)
end

collectgarbage()
-------------------------------

So, either you hit a more strange bug in Lua or the crashing is in
your code.

-- Roberto