lua-users home
lua-l archive

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


Alex Davies wrote:
I'm afraid I still can't imagine a scenario where that's possible. I mean, it doesn't keep dead keys around forever. Just until it needs to grow the table, and then it can remove them all.. and in doing so discover that it never needed to grow the table in the first place. The only way it could consume all available memory would be if at some point you had enough live keys in the table to do that.

Here is a pure-Lua test case that is very close to what my application is doing. (Change N if needed).
  local N = 6
  local tb = setmetatable ({}, { __mode="k" })
  print(collectgarbage"count")
  for n=1,N do
    for k=1,1e6 do tb[{}] = true end
    print(collectgarbage"count")
  end

--
Shmuel