Lua Garbage collector and weak tables

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


  1. collectgarbage(gcrule [, gcdata]) -- collect garbage using gcrule
  2. setmetatable(tab, {__mode = weakmode}) -- set weak mode of tab to weakmode


gcrule & gcdataAction to gc (garbage collector): "stop" (stop collecting), "restart" (start collecting again), "collect" or nil (collect all garbage), "step" (do one collecting step), "count" (return count of used memory in KBs), "setpause" and data is number from 0% to 100% (set pause parameter of gc), "setstepmul" and data is number from 0% to 100 (set "stepmul" for gc).
weakmodeType of weak table: "k" (only weak keys), "v" (only weak values), "vk" (weak keys and values)

Got any Lua Question?