summaryrefslogtreecommitdiff
path: root/script/provider/diagnostic.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-12-09 17:25:23 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-12-09 17:25:23 +0800
commita779b7dbbbfbd4a5a177ba44f0db131d1ce3c6a6 (patch)
treeb0ce64e12ddcbf7f564a08d162138341fe7fca86 /script/provider/diagnostic.lua
parentd1b6b518a28170b13ba1d83bd39a3c23efac04fd (diff)
downloadlua-language-server-a779b7dbbbfbd4a5a177ba44f0db131d1ce3c6a6.zip
do full gc after scope diag
#1745
Diffstat (limited to 'script/provider/diagnostic.lua')
-rw-r--r--script/provider/diagnostic.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index fd78b9c2..90c5a81c 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -508,11 +508,15 @@ local function askForDisable(uri)
end
end
-local function clearMemory()
+local function clearMemory(finished)
if m.scopeDiagCount > 0 then
return
end
vm.clearNodeCache()
+ if finished then
+ collectgarbage()
+ collectgarbage()
+ end
end
---@async
@@ -524,10 +528,11 @@ function m.awaitDiagnosticsScope(suri, callback)
while loading.count() > 0 do
await.sleep(1.0)
end
+ local finished
m.scopeDiagCount = m.scopeDiagCount + 1
local scopeDiag <close> = util.defer(function ()
m.scopeDiagCount = m.scopeDiagCount - 1
- clearMemory()
+ clearMemory(finished)
end)
local clock = os.clock()
local bar <close> = progress.create(suri, lang.script.WORKSPACE_DIAGNOSTIC, 1)
@@ -567,6 +572,7 @@ function m.awaitDiagnosticsScope(suri, callback)
end
bar:remove()
log.info(('Diagnostics scope [%s] finished, takes [%.3f] sec.'):format(scp:getName(), os.clock() - clock))
+ finished = true
end
function m.diagnosticsScope(uri, force)