From a779b7dbbbfbd4a5a177ba44f0db131d1ce3c6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 9 Dec 2022 17:25:23 +0800 Subject: do full gc after scope diag #1745 --- script/provider/diagnostic.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'script/provider/diagnostic.lua') 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 = util.defer(function () m.scopeDiagCount = m.scopeDiagCount - 1 - clearMemory() + clearMemory(finished) end) local clock = os.clock() local bar = 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) -- cgit v1.2.3