File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ local vm = require 'vm.vm'
2323local m = {}
2424m .cache = {}
2525m .sleepRest = 0.0
26+ m .scopeDiagCount = 0
2627
2728local function concat (t , sep )
2829 if type (t ) ~= ' table' then
@@ -466,6 +467,14 @@ local function askForDisable(uri)
466467 end
467468end
468469
470+ local function clearMemory ()
471+ if m .scopeDiagCount > 0 then
472+ return
473+ end
474+ vm .clearNodeCache ()
475+ collectgarbage ()
476+ end
477+
469478--- @async
470479function m .awaitDiagnosticsScope (suri , callback )
471480 local scp = scope .getScope (suri )
@@ -475,6 +484,11 @@ function m.awaitDiagnosticsScope(suri, callback)
475484 while loading .count () > 0 do
476485 await .sleep (1.0 )
477486 end
487+ m .scopeDiagCount = m .scopeDiagCount + 1
488+ local scopeDiag <close> = util .defer (function ()
489+ m .scopeDiagCount = m .scopeDiagCount - 1
490+ clearMemory ()
491+ end )
478492 local clock = os.clock ()
479493 local bar <close> = progress .create (suri , lang .script .WORKSPACE_DIAGNOSTIC , 1 )
480494 local cancelled
Original file line number Diff line number Diff line change @@ -9,8 +9,6 @@ local mathHuge = math.huge
99
1010local weakMT = { __mode = ' kv' }
1111
12- _ENV = nil
13-
1412--- @class vm
1513local m = {}
1614
You can’t perform that action at this time.
0 commit comments