Module:Sandbox/GC

local weak_table = {} setmetatable(weak_table, { __mode = 'v' })

weak_table.weak_value = {}

local function wait_for_gc(n) local gced = {} for i = 1, n do   table.insert(gced, i)  end end

return { test = function local total_inserts = 0 for n = 1, 1000000 do     wait_for_gc(n) total_inserts = total_inserts + n     if not weak_table.weak_value then mw.log("empty at " .. total_inserts) break end end end }