diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-12 18:12:44 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-12 18:12:44 +0800 |
commit | fe7b7bd71785844dd34aea9e2a1da9f8b9e6620a (patch) | |
tree | a7abc0fef99dff8e2c3f5a6262a7cc6bf8f51829 /server/src | |
parent | c0c6f06e5d3df777790fb0f209d53f38e38c34db (diff) | |
download | lua-language-server-fe7b7bd71785844dd34aea9e2a1da9f8b9e6620a.zip |
显示一下vm的数量以供调试
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/vm/vm.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 841b09ca..88a272de 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -1171,6 +1171,22 @@ local function compile(ast, lsp, uri) return vm end +-- TODO 测试代码 +local CachedVM = setmetatable({}, {__mode = 'kv'}) + +local function checkCachedVM(vm) + CachedVM[vm] = true + local total = 0 + local alive = 0 + for vm in pairs(CachedVM) do + total = total + 1 + if not vm:isRemoved() then + alive =alive + 1 + end + end + log.debug(('持有的VM:%d/%d'):format(alive, total)) +end + return function (ast, lsp, uri) if not ast then return nil @@ -1179,5 +1195,6 @@ return function (ast, lsp, uri) if not suc then return nil, res end + checkCachedVM(res) return res end |