Skip to content

Instantly share code, notes, and snippets.

@katlogic
Last active September 26, 2015 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save katlogic/b87fd56387bae9a56f58 to your computer and use it in GitHub Desktop.
Save katlogic/b87fd56387bae9a56f58 to your computer and use it in GitHub Desktop.
track={}
setmetatable(track,{__mode="k"})
function setmetatable52(t,v)
if v.__gc then
track[t] = newproxy(true)
getmetatable(track[t]).__gc = function(dummy)
v.__gc(t)
end
end
setmetatable(t,v)
end
t={}
print(t)
m={__gc=function(tt)
print('got call, now resurrecting',tt)
t=tt
setmetatable52(tt,m)
end}
setmetatable52(t,m)
t=nil
for i=1,10 do collectgarbage("collect") end
t=nil
for i=1,10 do collectgarbage("collect") end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment