summaryrefslogtreecommitdiff
path: root/server/src/vm
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-04 16:48:44 +0800
committersumneko <sumneko@hotmail.com>2019-04-04 16:48:44 +0800
commit88def129c6bbc7e1c2ae7e4fd670ed386f1e8e5e (patch)
tree733f4f9557eab8c7f55c113321f1cc961fa41edd /server/src/vm
parent38b43009f3325328630a4b9ee20d8cb9d8d9faf0 (diff)
downloadlua-language-server-88def129c6bbc7e1c2ae7e4fd670ed386f1e8e5e.zip
修正一些泄露,用了一些临时的办法中断编译链并清空缓存,以后重构
Diffstat (limited to 'server/src/vm')
-rw-r--r--server/src/vm/chain.lua11
-rw-r--r--server/src/vm/source.lua1
2 files changed, 12 insertions, 0 deletions
diff --git a/server/src/vm/chain.lua b/server/src/vm/chain.lua
index 23b38a75..55947105 100644
--- a/server/src/vm/chain.lua
+++ b/server/src/vm/chain.lua
@@ -21,6 +21,7 @@ function mt:clearCache()
if ok then
n = n + 1
else
+ value:getSource():kill()
self.cache[uri] = nil
end
end
@@ -42,6 +43,16 @@ function mt:get(uri)
return self.cache[uri]
end
+function mt:remove()
+ if self.removed then
+ return
+ end
+ self.removed = true
+ for _, value in pairs(self.cache) do
+ value:getSource():kill()
+ end
+end
+
return function ()
return setmetatable({
cache = {},
diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua
index ce1d325b..a969079b 100644
--- a/server/src/vm/source.lua
+++ b/server/src/vm/source.lua
@@ -2,6 +2,7 @@ local listMgr = require 'vm.list'
local mt = {}
mt.__index = mt
+mt.type = 'source'
mt.uri = '@dummy'
mt.start = 0
mt.finish = 0