diff options
-rw-r--r-- | script/provider/diagnostic.lua | 14 | ||||
-rw-r--r-- | script/vm/vm.lua | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 149e409f..583173f0 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -23,6 +23,7 @@ local vm = require 'vm.vm' local m = {} m.cache = {} m.sleepRest = 0.0 +m.scopeDiagCount = 0 local function concat(t, sep) if type(t) ~= 'table' then @@ -466,6 +467,14 @@ local function askForDisable(uri) end end +local function clearMemory() + if m.scopeDiagCount > 0 then + return + end + vm.clearNodeCache() + collectgarbage() +end + ---@async function m.awaitDiagnosticsScope(suri, callback) local scp = scope.getScope(suri) @@ -475,6 +484,11 @@ function m.awaitDiagnosticsScope(suri, callback) while loading.count() > 0 do await.sleep(1.0) end + m.scopeDiagCount = m.scopeDiagCount + 1 + local scopeDiag <close> = util.defer(function () + m.scopeDiagCount = m.scopeDiagCount - 1 + clearMemory() + end) local clock = os.clock() local bar <close> = progress.create(suri, lang.script.WORKSPACE_DIAGNOSTIC, 1) local cancelled diff --git a/script/vm/vm.lua b/script/vm/vm.lua index 5437b632..49edcff5 100644 --- a/script/vm/vm.lua +++ b/script/vm/vm.lua @@ -9,8 +9,6 @@ local mathHuge = math.huge local weakMT = { __mode = 'kv' } -_ENV = nil - ---@class vm local m = {} |