summaryrefslogtreecommitdiffhomepage
path: root/libs/core
diff options
context:
space:
mode:
Diffstat (limited to 'libs/core')
-rw-r--r--libs/core/luasrc/util.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua
index 3a0b2fbfc1..5168560572 100644
--- a/libs/core/luasrc/util.lua
+++ b/libs/core/luasrc/util.lua
@@ -281,6 +281,13 @@ function threadlocal()
rawset(self, thread, {})
end
rawget(self, thread)[key] = value
+
+ -- Avoid memory leaks by removing abandoned stores
+ for k, v in pairs(self) do
+ if type(k) == "thread" and coroutine.status(k) == "dead" then
+ rawset(self, k, nil)
+ end
+ end
end
setmetatable(tbl, {__index = get, __newindex = set})