Skip to content

Instantly share code, notes, and snippets.

@lvzixun
Created November 3, 2016 10:13
Show Gist options
  • Save lvzixun/3aeaf3c4ea29d9e6230df96f0de238e2 to your computer and use it in GitHub Desktop.
Save lvzixun/3aeaf3c4ea29d9e6230df96f0de238e2 to your computer and use it in GitHub Desktop.
local a = setmetatable({}, {__mode = "kv"})
local c = nil
local b = setmetatable({}, {
__gc = function (self)
print("self:", self)
print("weak value:", a.test_value)
c = self
end
})
print("b", b)
a.test_value = b
b = nil
collectgarbage("collect")
print("end:", a.test_value, "c:", c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment