summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-13 16:22:46 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-13 16:22:46 +0800
commit42ec4d53d770a053c0909f14b5aa7c8cd42bbcdb (patch)
tree5199ab76c711e828dd2fc623c6a2744e10931acb
parent745a3fe1a9d33584fcda6abd5925af544f4897e3 (diff)
downloadlua-language-server-42ec4d53d770a053c0909f14b5aa7c8cd42bbcdb.zip
source失效时解除绑定引用
-rw-r--r--server/src/service.lua1
-rw-r--r--server/src/vm/source.lua9
-rw-r--r--server/src/vm/vm.lua2
3 files changed, 11 insertions, 1 deletions
diff --git a/server/src/service.lua b/server/src/service.lua
index 80b6bcb6..ba45f9f4 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -534,6 +534,7 @@ function mt:onTick()
self:_doCompileTask()
if os.clock() - self._clock >= 60 then
+ collectgarbage()
self._clock = os.clock()
local count = 0
for _ in pairs(self._file) do
diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua
index 247788b0..d53019c7 100644
--- a/server/src/vm/source.lua
+++ b/server/src/vm/source.lua
@@ -80,6 +80,15 @@ function mt:getName()
return self[1]
end
+function mt:kill()
+ self._dead = true
+ self._bindLocal = nil
+ self._bindValue = nil
+ self._bindCall = nil
+ self._bindFunction = nil
+ self._bindCallArgs = nil
+end
+
function mt:isDead()
return self._dead
end
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua
index 00fce559..d9d29886 100644
--- a/server/src/vm/vm.lua
+++ b/server/src/vm/vm.lua
@@ -1150,7 +1150,7 @@ function mt:remove()
end
self._removed = true
for _, source in ipairs(self.sources) do
- source._dead = true
+ source:kill()
end
end